2024年06月25日 建站教程
es6语法中map()函数有什么用,下面web建站小编给大家简单介绍一下map()的运用方法!
代码介绍:
const array = [2, 3, 4, 4, 5, 6]
const map = array.map(x => {
if (x == 4) {
return x * 2
}
return x
})
console.log("map",map)
const array = [2, 3, 4, 4, 5, 6]
const map2=array.map((item,index,arr)=>{
return item*2
})
console.log("map2",map2)
本文链接:http://so.lmcjl.com/news/7237/