How to Print a Message to the Error Console Using JavaScript
Printing in the console is easy and at the same time an interesting thing. The console in JavaScript is an object providing access to the browser debugging console. It has many methods that help to print customized debugging. You can use the console object to output a message to the error console.
The following example displays the default message:
This example shows a red error message:
This gives a warning message with the exclamation mark in front of it:
This example outputs an information message with an 'i' letter in front of the message:
You can use the console.error method to print error. Here "x" is the variable's name:
The console.error outputs an error message to the Web Console. The console.exception() method is the alias for console.error(). Functionally, they do the same thing.