const sum = (function() {
"use strict";
return function sum(...args) {
return args.reduce((a, b) => a + b, 0);
};
})();
console.log(sum(1,2,3,4))
答案 0 :(得分:1)
除去所有噪音后,代码为
const sum = (...args) => args.reduce((a, b) => a + b, 0)
是
...args
)args
)reduce
0
reduce
步骤上,将当前值b
添加到累加器a
答案 1 :(得分:0)
...args //The rest parameter syntax allows us to represent an indefinite number of arguments as an array.