TypeError: Illegal Invocation on console.log.apply

JavascriptGoogle ChromeConsole

Javascript Problem Overview


If you run this in the chrome console:

console.log.apply(null, [array])

Chrome gives you back an error:

// TypeError: Illegal Invocation

Why? (Tested on Chrome 15 via OSX)

Javascript Solutions


Solution 1 - Javascript

It may not work in cases when execution context changed from console to any other object:

> This is expected because console.info expects its "this" reference to > be console, not window. > > console.info("stuff") > stuff > undefined > console.info.call(this, "stuff") > TypeError: Illegal invocation > console.info.call(console, "stuff") > stuff > undefined > > This behavior is expected.

https://bugs.chromium.org/p/chromium/issues/detail?id=48662

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJacksonkrView Question on Stackoverflow
Solution 1 - JavascriptPavel PodlipenskyView Answer on Stackoverflow