Logging or printing messages to the console is a very basic way to diagnose and troubleshoot minor issues or bugs in your code.
In this article, I'll show you how to print to the console in JS, as well as all of the things you didn't know console could do.
Print string, number or boolean values in console
console.log('Hi there');
console.log(10);
console.log(false);
Print the value of a variable
let say = 'Hello';
console.log(say);
- Print an array to console
let quote = ['Keep','it','simple'];
console.log(quote);
- Print an object to console using log and table method
let person = {
id:002,
age:20,
job:'tech'
}
console.log(person);
console.table(person);
Top comments (0)