Writing to the JavaScript Console

console.log("This is Debug"); //"This is Debug" is displayed in console var x=5; console.log("x="+x): //"x=5" is displayed in console

The JavaScript console can be an important tool when debugging problems in your jQuery and JavaScript code. The console log is simply a location where you can view data output from the JavaScript code. Each of the major browsers has a console log tool that displays the output.

To output data to the console log, use console.write(DEBUG_STRING) and pass it the text that you want to display on the console.

Get jQuery and JavaScript Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.