124
非法调用如果您在Chrome控制台运行此:类型错误:在console.log.apply
console.log.apply(null, [array])
铬给你回一个错误:
// TypeError: Illegal Invocation
为什么? (通过OSX测试在Chrome 15)
非法调用如果您在Chrome控制台运行此:类型错误:在console.log.apply
console.log.apply(null, [array])
铬给你回一个错误:
// TypeError: Illegal Invocation
为什么? (通过OSX测试在Chrome 15)
它可能不会在情况下工作时执行上下文从控制台变更为任何其他对象:
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.
如果你需要一个功能使用,你可以使用console.info.bind(console) –
,所以你可以在所有支持ES5的浏览器中使用'console.info.call(console,“stuff”)'? – mucaho
同样适用于:'console.info.apply(console,arguments)' – PeterM