📅  最后修改于: 2022-03-11 15:01:47.191000             🧑  作者: Mango
function sum() {
// "arguments" is an object that can be converted to an Array
const args = Array.from(arguments);
return args.reduce((acc, next) => acc + next);
}
sum(1, 2); // 3
sum(1, 2, 3); // 6
sum(1, 2, 3, 4); // 10