JavaScript console tips and tricks

The usage of JavaScript console to the JavaScript developer are huge. It a part of debugging or retrieving mystery of JavaScript code. Sometimes it is important to know about different usage of JavaScript console. Most of the console operation can be done on user browsers.

Following are some tips of JavaScript console that we can use everyday:

Console for printing multiple values

We can print multiple variables using JavaScript console like below:

console.log(name, email, status);

Console.clear() to clear the console

We can clear the console using clear method or we can use keyboard shortcut to clear the console like below:

console.clear()
OR
Ctrl + l

Basic console functions

We can clear the console using clear method or we can use keyboard shortcut to clear the console like below:

console.log('Output a message'); //log a message or an object to console
console.info('Print the info'); //same as console log
console.warn('Warning happened'); //same as console log but outputs a warning
console.error('Something went wrong'); //same as console log but outputs an error

Heap memory size using console.memory

We can very easily check the browser JS heap memory size using JavaScript console like below: