js之argument小解

参考https://www.cnblogs.com/gongyijie/p/9425549.html

1 var i = 0;
2 var result = 0;
3 function sum(){
4     for(i = 0; i < arguments.length; i++){
5         result += arguments[i];
6     }
7     return result;
8 }
9 alert(sum(1,2,3,4,5,6));

 

posted @ 2019-05-07 14:11  WETYUIOASHZXCVBNM  阅读(169)  评论(0编辑  收藏  举报