Javascript Array map(cb)

Description

Javascript Array map(cb)


//Implement map function for Array
Array.prototype.map = function(cb){
    var arr = Object(this);
    var res = []//from ww w . j  a va2s  .c  o  m
    for(var i=0;i<arr.length;i++){
        res[i] = cb.call(arr[i], i);
    }
    return res;
}



PreviousNext

Related