- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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.
- Related Articles
- How do I print Unicode characters in the console using JavaScript?
- How do I print debug messages in the Google Chrome JavaScript Console?
- How to print colored text in the console using JavaScript?
- How can I verify Error Message on a webpage using Selenium Webdriver?
- JavaScript Error message Property
- How to print a line on the console using C#?
- How to create a Tkinter error message box?
- How to change the color of error message in jquery validation in JavaScript?
- How I can change alert message text color using JavaScript?
- How to change MySQL error message language?
- Display a message on console while focusing on input type in JavaScript?
- Can I extend a JavaScript error? What is the best way to do so?
- How to send message from firebase console after creation project?
- How can I clear console using C++?
- Getting error message while using SAP Scripting Tool

Advertisements