Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
How do I print a message to the error console using JavaScript?
To print a message to the error console, use the console object. Here’s an example −
The following will show a red error message −
console.error(message);
The following gives you the default message −
console.log(message);
The following gives you the warning message −
console.warn(message);
The following gives an information message −
console.info(message);
Add CSS to the log message −
console.log('%c Add message!, "background: green; color: white;");
Use the following to print error. Consider “num” as the variable name −
console.error('num=%d', num);
For complete API reference, refer Console API Reference.
Advertisements
