Wen*_* Du 16 javascript google-chrome v8 node.js optional-chaining
注意:代码使用的是spread syntax,而不是rest parameters。
const fn1 = undefined
const args = []
const fn2 = () => {}
const fn3 = () => {}
console.log(fn1?.(...args, fn2, fn3))
Run Code Online (Sandbox Code Playgroud)
错误:
console.log(fn1?.(...args, fn2, fn3))
^
TypeError: Function.prototype.apply was called on undefined, which is an undefined and not a function
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
652 次 |
| 最近记录: |