标签:blog io ar 使用 java for on 2014 log
Array.prototype.sum= function(l,r){ l=l==undefined ? 0 : l; r=r==undefined ? this.length - 1 : r; var s = 0; for(var i = l;i <= r;i++){s+=this[i];} return s; }
使用:
var ar = new Array(1,3,4,-1,-2,3,4,-2,4); console.log(ar.sum(0,2))
标签:blog io ar 使用 java for on 2014 log
原文地址:http://blog.csdn.net/lan_liang/article/details/40455145