3 ms·
What do you think happens when you pass arguments to functions like that?
by Inviz 15y ago
What do you think happens when you pass arguments to functions like that?
- jdunck 15y agowindow.console.log.apply(window.console, arguments)
- Inviz 15y agoSee? There's the problem. Since there's no conclusion between vendors on console object API, console.log function may not have .apply method. It's not only the console object functions actually, most of the browsers choke on a [1,2,3].forEach(alert) and other [Native Code] functions.
- gonchuki 15y agoFunction.prototype.apply.apply(console.log, [console, arguments]); Works both on IE9 broken console.log, and regular console.log from other vendors. Same hack as using Array.prototype.slice to convert arguments into a real array.