Open egoist opened 8 years ago
在 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)
参考资料:
How about ...{}?
...{}
在 ES5 中把函数参数转换为数组:
在 ES6 中:
反之,把数组转换为函数参数来使用:
参考资料: