I did this in my Angular application:
var cl = console.log; cl(123);
however, I got the following error message:
Uncaught TypeError: Illegal invocation
This happened in Chrome. He works at Nodejs.
I'm confused. Is this an illegal code?
clonly refers to a method log(). log()expects consoleas a context, but receives window. To solve, bind consoleas a context:
cl
log()
console
window
var cl = console.log.bind(console); cl("Hello");