SOURCE

function test(...rest) {
    // let arr = rest
    return rest.flat(Infinity).reduce((sum, num) => sum + Number(num), 0)
}

console.log(test(1, 2, 3, 4))
console.log(test([1, 2, 3, 4]))
console 命令行工具 X clear

                    
>
console