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

ES6 数组去重 #57

Open
hsipeng opened this issue Jun 23, 2018 · 0 comments
Open

ES6 数组去重 #57

hsipeng opened this issue Jun 23, 2018 · 0 comments

Comments

@hsipeng
Copy link
Owner

hsipeng commented Jun 23, 2018

    1. Set + Array.from()
var temp = [1, 1, 2, 2, 33, '33', 44, '44']
var set = new Set(temp)
console.log(set) // {1, 2, 33, '33', 44, '44'}
var setArr = Array.from(set)
console.log(setArr) // [1, 2, 33, '33', 44, '44']
    1. … [拓展运算] + Set
var tt = [...new Set([1, 1, 2, 2, 33, '33', 44, '44'])]

console.log(tt) // [1, 2, 33, '33', 44, '44']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant