标签:
1.普通求和
function sum(){ var result=0; for(var i=0;i<arguments.length;i++){ result+=arguments[i]; } return resulat; } alert(sum(2,5));
2.面向对象
var arr=[2,5]; Array.prototype.sum=function(){ var result=0; for(var i=0;i<this.length;i++){ result+=this[i] } return resulat; }; alert(arr.sum());
标签:
原文地址:http://www.cnblogs.com/binlucky/p/5343547.html