1 //求任意个数的和 2 function test() { 3 var sum = 0; 4 for (var i = 0; i < arguments.length; i++) { 5 sum += arguments[i] 6 }; 7 return sum; 8 } 9 10 var ret = test(1,2,3,4); 11 console.log(ret);