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
function foo() {
for (var i = 0; i < arguments.length; i++) {
console.log(arguments[i]);
}
}
function manyArgs() {
for (var i = 0; i < arguments.length; ++i)
alert(arguments[i]);
}