Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

数组去重方法 #17

Open
myheartwillgoon opened this issue Oct 23, 2018 · 0 comments
Open

数组去重方法 #17

myheartwillgoon opened this issue Oct 23, 2018 · 0 comments

Comments

@myheartwillgoon
Copy link
Owner

myheartwillgoon commented Oct 23, 2018

ES2015 Set

Array.from(new Set(arr))

filter 索引对比

arr.filter((item, index) => arr.indexOf(item) === index)

对象属性

const map = Object.create(null)
arr.filter(item => map[item] ? false : (map[item] = 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant