When I execute the following code in Chrome 18 beta I get the error:
console.log.apply(this, ['message']);
TypeError: Illegal invocation.
In Firefox 10 it works as expected.
In IE9 I get the error: Object doesn't support property or method 'apply'.
I’m guessing this has to do with how the browser has implemented console.log.
Why does it work in Firefox but not in Chrome and IE? I’m hoping someone can shed some light on the cause of this and its ramifications.
Here is an executable sample on JS Bin.
consoleandlogare host objects. Their behavior is implementation dependent, and to a large degree are not required to implement the semantics of ECMAScript.FWIW, your jsBin fails in Chrome as well unless you change it to…
but that seems to be that
logsimply anticipates a calling context ofconsole.