数组去重
[1,23,23,43,512].reduce((pre,cur)=>{
if (!pre.includes(cur)) {
pre.push(cur)
}
return pre
}, [])
运行结果 [1, 23, 43, 512]
数组去重
[1,23,23,43,512].reduce((pre,cur)=>{
if (!pre.includes(cur)) {
pre.push(cur)
}
return pre
}, [])
运行结果 [1, 23, 43, 512]
本文标题:Array对象reduce方法
本文链接:https://www.haomeiwen.com/subject/sccqwhtx.html
网友评论