Using the console

suggest change

In many environments, you have access to a global console object that contains some basic methods for communicating with standard output devices. Most commonly, this will be the browser’s JavaScript console (see Chrome, Firefox, Safari, and Edge for more information).

// At its simplest, you can 'log' a string
console.log("Hello, World!");

// You can also log any number of comma-separated values
console.log("Hello", "World!");

// You can also use string substitution
console.log("%s %s", "Hello", "World!");

// You can also log any variable that exist in the same scope
var arr = [1, 2, 3];
console.log(arr.length, this);

You can use different console methods to highlight your output in different ways. Other methods are also useful for more advanced debugging.

For more documentation, information on compatibility, and instructions on how to open your browser’s console, see the Console topic.

Note: if you need to support IE9, either remove console.log or wrap its calls as follows, because console is undefined until the Developer Tools are opened:

if (console) { //IE9 workaround
    console.log("test");
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Debugging:
* Using the console

Table Of Contents
11 Arrays
12 Objects
14 Classes
16 Map
17 Set
24 Loops
27 Date
29 Scope
30 AJAX
35 Cookies
41 JSON
44 Fetch
45 Modules
46 Screen
51 Debugging
64 Console
68 Symbols
73 Modals
76 Events
86 Proxy
89 WeakMap
90 WeakSet
102 Tilde