在 ES5 中把函数参数转换为数组:
function foo() {
console.log([].slice.call(arguments))
}
foo(1, 2, 3)
// yield [1, 2, 3]
在 ES6 中:
function foo(...args) {
console.log(args)
}
foo(1, 2, 3)
// yield [1, 2, 3]
反之,把数组转换为函数参数来使用:
Math.max(...[13, 7, 30])
// equals to
Math.max(13, 7, 30)
参考资料:
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too