Javascript Array reduce(cb, res)

Description

Javascript Array reduce(cb, res)


//Implement reduce function for Array
Array.prototype.reduce = function(cb, res){
    var arr = Object(this);
    for(var i=0;i<arr.length;i++){
        res = cb.call(res, arr[i], i);/*from   w ww.j a va  2  s.  c  om*/
    }
    return res;
}



PreviousNext

Related