thisValue 表示执行回调函数 callback() 时的 this 指向。可选参数。当不写时,则默认是指向 window 全局
手写 map
简单版
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Array.prototype._map = function (fn) { if (typeof fn !== 'function') return'fn is not a function' let temp = [] const arr = this for(let val of arr) { temp.push(fn(val)) } return temp }