JavaScript console.log() Examples

console.log() is a useful JavaScript method to print data into developer’s console.

//Syntax
console.log(x);

X can be of any data types, be it a string, or an inter, or an object. If the x doesn’t exist, it prints out error: Uncaught ReferenceError: x is not defined.

var str = "Tl Templates"; 
console.log(str); 

var brands = ['Honda', 'Huyndai', 'Toyota', 'BMW'];
console.log(brands); 
console.log(5+10);
console.log('He is ' + 15 + ' years old');

Leave a Comment

Your email address will not be published.