其他分享
首页 > 其他分享> > Array.prototype.map()

Array.prototype.map()

作者:互联网

Array.prototype.map()

遍历加工,不改变原数组,与foreach相似,但优于foreach

const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
words.map(item => {
    console.log(item);
});
const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
let a = words.map(item => {
    return 1
});
console.log(a);  //[ 1, 1, 1, 1, 1, 1 ]

标签:map,console,item,foreach,words,exuberant,Array,prototype
来源: https://www.cnblogs.com/zhumenglong/p/16371957.html