I am a little confused by this. Please find the code as shown below.
var o={ printToConsole: function(f){ f(1); } }; o.printToConsole(console.log);
//TypeError: Illegal invocation // I get a TypeError
From the definition of console.log we get this
`function log() { [native code] }`
In chrome, which clearly shows that it takes no arguments, although when we try to print information to the console, we write like this: pass the argument console.log.
console.log('Take me on Console');
Why am I getting this TypeError and how does this console.log behave in chrome?
source share