How to Use Console.log in Javascript

The Javascript command console.log allow us to “Print Out” to the console.  When you need to see what the computer is processing you have to ask it to show you.  The correct way to write the code is like this:

console.log("show everything between these parentheses")

This command will log to the console anything within the parentheses including strings and equations. Here are two examples:

console.log(8 * 10);
console.log("Nice to be able to see what the interpreter, the computer, is working on.");

2 Responses to “How to Use Console.log in Javascript”

  1. Kevin Santoso

    But then what is the difference between console log and normal without console log? the console will still display the same for the 8*10 which is 80 wouldn’t it?

    • Console.log is a great tool for recording information about what javascript is doing. It isn’t displayed to the end user and is typically used for debugging purposes where someone who knows how can open the console and view information such as errors or other things one wishes to output. Typically, logging something to the console is an extra step and not critical to functionality of one’s project.

      I hope this helps.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>