Recipe 16.2

Using Log Levels

In addition to console.log, you can also call console.warn and console.error to get stylized output depending on the desired log level.

Demo

Open the console to see output.

Code

JavaScript
console.info('This is a log message');
console.warn('This is a warning message');
console.error('This is an error message');
HTML
Open the console to see output.
Web API Cookbook
Joe Attardi