Sets aren't usually created directly. Instead, you convert lists of values that might have duplicates into sets to remove the duplicates.
Assuming that you have a list that might contain duplicate values, you can convert the list to a set, as follows:
const myList = List.of(1, 1, 2, 2, 3, 3); const mySet = myList.toSet(); console.log('myList', myList.toJS()); // -> myList [ 1, 1, 2, 2, 3, 3 ] console.log('mySet', mySet.toJS()); // -> mySet [ 1, 2, 3 ]
As you can see, mySet
has unique values from myList
. The problem now is that you need to be able to use these unique values as part of an indexed collection. In other words, you need to convert the set back into a list.