How to Send Messages to the Console in JavaScript


show more The console helps JavaScript developers better understand their own code. Learn how to send messages to the console that other developers can read using a tool like Firebug. You can use this technique to measure performance, see how long scripts take to run, and more. show less
please wait ...

Sending messages to the console

I've been using this alert box because we need some way of getting a message out of JavaScript, but it is kind of annoying, particularly if I have several of them, because it requires that I click the OK button to dismiss it. And it's certainly not going to be what we want to do much more except in real alert circumstances. But luckily, we have Firebug, and having Firebug gives us something very useful here. Instead of alert, from now on what I'm going to do when I want the same equivalent is I am going to change that to console.log, leaving everything else the same.

This is all written in lowercase. As you can see, I have three statements here that all call console.log. Now if I run this one again, instead of having the alert box pop up in the page section, I'm actually getting a pop-up over here in the actual console, which is part of Firebug. Console.log is not officially part of the JavaScript language. It's an add-on that Firebug is bringing to the party, althoug...

Sending messages to the console
Video duration: 2m 59s 5h 31m Beginner

Viewers:

The console helps JavaScript developers better understand their own code. Learn how to send messages to the console that other developers can read using a tool like Firebug. You can use this technique to measure performance, see how long scripts take to run, and more.

Subjects:
Developer Web
Software:
JavaScript
Author:
please wait ...