📜  javascript代码示例中的加法参数

📅  最后修改于: 2022-03-11 15:03:40.808000             🧑  作者: Mango

代码示例1
function addNumbers(num1, num2) {
    let sum = 0;
    for (const num of arguments) {
        sum = sum + num;
    }
    return sum;
}
const sum = addNumbers(1, 2, 3, 4, 5)
console.log(sum);
//Output: 15