题解 | #数组去重#

数组去重

http://www.nowcoder.com/practice/0b5ae9c4a8c546f79e2547c0179bfdc2

Array.prototype.uniq = function () {
 let arr=this
 //循环数组插入Set
 let set=new Set()
 arr.forEach(item=>{
    set.add(item)
 })

    return Array.from(set)
}
全部评论

相关推荐

点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务