Logo

Programming-Idioms

History of Idiom 118 > diff from v65 to v66

Edit summary for version 66 by programming-idioms.org:
[JS] Better demo link (shows code)

Version 65

2022-02-24, 18:09:04

Version 66

2022-02-24, 18:09:17

Idiom #118 List to set

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

Turning the list [a,b,c,b] into the set {c,a,b}

Idiom #118 List to set

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

Turning the list [a,b,c,b] into the set {c,a,b}
Variables
y,x
Variables
y,x
Code
var y = new Set(x);
Code
var y = new Set(x);
Comments bubble
The Set function was added to JS in ES2015 (a.k.a ES6).
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
Doc URL
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
Demo URL
https://repl.it/@ProgIdioms/CalmFloweryApplicationsoftware
Demo URL
https://replit.com/@ProgIdioms/CalmFloweryApplicationsoftware#index.js