题解 | #数组去重#

数组去重

https://www.nowcoder.com/practice/7a26729a75ca4e5db49ea059b01305c9

1 使用 filter + indexOf

const array = [1,3,4,5,3,2,3,9]

function unique (){

return array.filter((item,index)=>{

return array.indexOf(item) === index

})

}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务