How to transform the values of Javascript ES6 Set wrapper into a plain Object? Especially: What is the fastest/shortest way to do so?
I am looking for something like the following that applies to Arrays:
const myArray = Array.from(mySet);
I tried in vain:
// mySet variable is Set containing integers {1, 2, 3, ..., n}
Object.assign({}, mySet);
Object.assign({}, mySet.values());
Object.assign({}, mySet.entries());
Finally, I am thinking about creating a new object, iterating over the set and pushing its entries into the new object. I wonder if there is a more elegant way to do so.
const myObject = {1, 2, 3, ..., n};Object.assign( {}, [ ...mySet ])