EN
JavaScript - convert Set to Array
3 points
In this article, we would like to show you how to convert Set to Array in JavaScript.
Quick solution:
xxxxxxxxxx
1
const array = Array.from(set);
xxxxxxxxxx
1
const set = new Set([1, 2, 3]);
2
const array = Array.from(set); // <----- conversion
3
4
console.log(array);
xxxxxxxxxx
1
const set = new Set([1, 2, 3]);
2
const array = [set]; // <----- conversion
3
4
console.log(array);