Logo

Programming-Idioms

History of Idiom 118 > diff from v9 to v10

Edit summary for version 10 by :
New JS implementation by user [Patman64]

Version 9

2016-02-16, 18:00:30

Version 10

2016-02-16, 20:15:45

Idiom #118 List to set

Create set y from list x.
x may contain duplicates. y is unordered and has no repeated values.

Idiom #118 List to set

Create set y from list x.
x may contain duplicates. y is unordered and has no repeated values.

Code
var y = new Set(x);
Comments bubble
The Set function was added to JS in ES2015 (a.k.a ES6).
Doc URL
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set