注意:代码使用
spread syntax
,而不是 rest parameters
. const fn1 = undefined
const args = []
const fn2 = () => {}
const fn3 = () => {}
console.log(fn1?.(...args, fn2, fn3))
错误:console.log(fn1?.(...args, fn2, fn3))
^
TypeError: Function.prototype.apply was called on undefined, which is an undefined and not a function
最佳答案
原来是V8的bug,我已经提交了there ,希望它会尽快修复。
更新:it has been fixed .
关于javascript - 可选链接 - Function.prototype.apply 在未定义时调用,这是未定义而不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66609657/