What is console.log?

前端 未结 22 2317
面向向阳花
面向向阳花 2020-11-22 00:41

What is the use of console.log?

Please explain how to use it in JavaScript, with a code example.

22条回答
  •  执念已碎
    2020-11-22 01:26

    In early days JS debugging was performed through alert() function - now it is an obsolete practice.

    The console.log() is a function that writes a message to log on the debugging console, such as Webkit or Firebug. In a browser you will not see anything on the screen. It logs a message to a debugging console. It is only available in Firefox with Firebug and in Webkit based browsers (Chrome and Safari). It does not work well in all IE releases.

    The console object is an extension to the DOM.

    The console.log() should be used in code only during development and debugging.

    It’s considered bad practice that someone leaves console.log() in the javascript file on the production server.

提交回复
热议问题