js 数组去重

const quchong = (arr) => {
return [...new Set(arr)]
}

const quchong = (arr) => {
const res = []
arr.reduce((pre, next) => {
if (!pre.has(next)) {
pre.set(next, 1)
res.push(next)
}
return pre
}, new Map())

return res
}

js 数组去重最先出现在Python成神之路

版权声明:
作者:主机优惠
链接:https://www.techfm.club/p/25166.html
来源:TechFM
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>