How to get unique values in an array [duplicate]

Here’s a much cleaner solution for ES6 that I see isn’t included here. It uses the Set and the spread operator: ...

var a = [1, 1, 2];

[... new Set(a)]

Which returns [1, 2]

Leave a Comment