Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript: How do I print a message to the error console?

How can I print a message to the error console, preferably including a variable?

For example, something like:

print('x=%d', x); 
like image 758
Mark Harrison Avatar asked Oct 02 '08 20:10

Mark Harrison


People also ask

Can you print to Console from JavaScript?

JavaScript does not have any print object or print methods. You cannot access output devices from JavaScript. The only exception is that you can call the window.print() method in the browser to print the content of the current window.

How do I use Console error message?

To log out your own error message you can check if the element exists or not. Use console. error and pass an error message if the element doesn't exist.

Which code will help writes an error message to the Console?

The error() method writes an error message to the console.

How do I print messages from Console log?

log() is a function in JavaScript which is used to print any kind of variables defined before in it or to just print any message that needs to be displayed to the user. Syntax: console. log(A);


1 Answers

Install Firebug and then you can use console.log(...) and console.debug(...), etc. (see the documentation for more).

like image 119
Dan Avatar answered Sep 23 '22 13:09

Dan