map

作者: bestCindy | 来源:发表于2020-10-06 23:15 被阅读0次
Array.prototype.map2 = function (fun) {
    let resArr = [];
    for (let i = 0; I < this.length; i++) {
        resArr.push(fun(this[i], i, this))
    }
    return resArr;
}
function ArrReduce(e) {
    return e * 2;
}
var arr = [1, 2, 3];
var res = arr.map2(ArrReduce)
console.log(res)//[2,4,6]

相关文章

网友评论

      本文标题:map

      本文链接:https://www.haomeiwen.com/subject/xguxpktx.html