The console is a global variable and can be used without the window prefix.


Passing Variables

Using comma's
Spaces will be automatically added between each argument during concatenation

console.log("value of var1 is:", var1, "and var2 is:", var2); 
console.log(var1 + var2);
console.log(var1, var2);

Using placeholders

console.log('%p - %p', var1, var2) 

Using backticks and template strings, added ES 2015

console.log(`${var1} - ${var2}`) 

Defining Functions

You can define the function as an anonymous lambda function

catch(function(e) { 

Or you can just pass the function itself when the argument is the same


© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext