window.console.log
The console is a global variable and can be used without the window prefix.
window.console.log
console.log
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) {
console.log(e)
});
Or you can just pass the function itself when the argument is the same
catch(console.log);
© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext