function sum(list){
return eval(list.join("+"))
}
//测试
alert(sum([1,4,9,16]))
</script>
var sum = function(a,b,c){return a + b + c
}
var result = sum(1,2,3) // 1+2+3
// 不限参数个数的
var sum2 = function(){
var res = 0
for(var i=arguments.length - 1i>=0i--){
res += arguments[i]
}
return res
}
var res1 = sum2(1,2,3) // 1+2+3
var res2 = sum2(1,2,3,4,5,6,7) // 1+2+3+4+5+6