console.log("This is a log message");
console.log("Message one", "Message two", "Message three");
To open the console, you can find it in Safari by looking for the the Web Inspector, in Chrome it’s called Developer Tools, and in Firefox you’ll find it under the Tools menu as Web Console.
The console object has a lot of useful debugging messages for errors with different severity, such as log, debug, info, warn, and error.
console.warn("Do I smell smoke?");
console.error("The roof, the roof, the roof is on fire.");
In Chrome and Safari, you can also use dirxml to display the a HTML element object in the console as HTML. In my version of Firefox, this method did not work.
You can also group related log messages, no matter their severity. To group console messages surround them with a group and groupEnd. You can even nest groups inside of groups.
// ... any number of console log messages.
// ... some time consuming code
When the timeEnd method is executed it will generate a message in the log console with the amount of time it took to run the code between the time and timeEnd method.
Chrome Developer Tools Web Console