if no such option exists, then maybe there is a nice idiomatic one-liner for doing that ? like, using for...of, or similar ?
Indeed, there are several ways to convert a Set to an Array:
using Array.from
let array = Array.from(mySet);
Simply spreading
the Set out in an array
let array = [...mySet];
The old fashion way, iterating and pushing to a new array (Sets do have forEach
)
let array = [];
mySet.forEach(v => array.push(v));
Previously, using the non-standard, and now deprecated array comprehension syntax:
let array = [v for (v of mySet)];