
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)
上面是“es6语法中map()的运用方法”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_2993.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

国家博物馆:拥有超过140万件藏品,包括古代文物、近现代文物等
js代码中replace的替换方法
震撼来袭!AI浏览器新功能:2分钟搞定视频简介、字幕、重点,自动生成思维导图!