Javascript Array map(iteratee, thisArg)

Description

Javascript Array map(iteratee, thisArg)



Array.prototype.map = function(iteratee, thisArg) {
 if (typeof iteratee !== "function") {
  throw new TypeError(iteratee + ' is not a function')
 }
 let arr = [];//w  w  w.j  a va2 s .c o m
 for (let i = 0, len = this.length; i < len; i++) {
  arr.push(iteratee.call(thisArg, this[i], i, this));
 }
 return arr;
}



PreviousNext

Related