What is console.log?

前端 未结 22 2358
面向向阳花
面向向阳花 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:22

    You can view any messages logged to the console if you use a tool such as Firebug to inspect your code. Let's say you do this:

    console.log('Testing console');
    

    When you access the console in Firebug (or whichever tool you decide to use to inspect your code), you will see whatever message you told the function to log. This is particularly useful when you want to see if a function is executing, or if a variable is being passed/assigned properly. It's actually rather valuable for figuring out just what went wrong with your code.

提交回复
热议问题