var a =[1,2,3,4,5]; var b =0; for(var i=0;i<a.length;i++){ // b=a[i]+b; //和下面的写法等同 b+=a[i] } console.log(b) //15