Array.prototype.sum = function(){ for(var i=0,sum=0;i call this as alert(yourarray.sum())