The Map method is defined in JavaScript Advanced Programming as running a given function on each item in an array and returning an array of the results of each function call.

Array.prototype._map = function (fn) { const _arr = [] if (! Array.isArray(this) || this.length < 1 || typeof fn ! == 'Function') return for (let i = 0; i < this.length ; i ++) { _arr.push(fn(this[i], i, this)) } return _arr } const arr = [1, 2, 3] arr._map((item, index, arr) => { return item+1 }) // [2, 3, 4]Copy the code