DEV Community

Discussion on: Implementing our own Array.map() method in javascript

Collapse
 
ashwaniweb profile image
Worried Indian • Edited

Array.prototype.myMap= function (callback) {
let result = this;
for (let index = 0; index < this.length; index++) {
if (this[index] === undefined) {
break;
}
result[index] = callback(this[index], index, this);
}
return result;
};