Set to array
Published: November 17, 2019
If you have a Set and want to transform it into an array you can do it with the spread syntax
js
const uniqueNumbers = new Set([1, 1, 4, 5, 4])
const arr = [...uniqueNumbers]
So a fancy way of getting unique values is casting an array back and forth:
js
let arr = [1, 1, 4, 5, 4]
arr = [...new Set(arr)]