How do I print debug messages in the Google Chrome JavaScript Console?

JavascriptWeb DevelopmentFront End Technology

To print debug messages in the Google Chrome JavaScript Console, write a script, which is not creating console functions if they do not exist −

if (!window.console) console = {};
console.log = console.log || function(){};
console.warn = console.warn || function(){};
console.error = console.error || function(){};

Above you can see the following functions are used to log items based on a log, warn or info. It won’t cause errors when the console isn’t available. The following functions work in Google Chrome console −

console.log( );

The Console object is used to access the browser's debugging console. As an example, consider the Web Console in Firefox. We’ve used console.log for getting the general output of log information.
The console.warn() is used to show a warning message.

Published on 03-Feb-2018 15:25:56