gpt4 book ai didi

javascript - 类型错误 : Illegal Invocation on console. log.apply

转载 作者:IT王子 更新时间:2023-10-29 02:38:11 26 4
gpt4 key购买 nike

如果您在 chrome 控制台中运行它:

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

Chrome 返回一个错误:

// 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.

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

关于javascript - 类型错误 : Illegal Invocation on console. log.apply,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8159233/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com