September 2017
Intermediate to advanced
216 pages
6h 8m
English
Once we've converted our list to a set, we'll have removed any duplicates. However, we do useful things with lists, such as getting values at a specific index or iterating over values in a consistent order. To do this, we'll convert our set back to a list, as shown here:
const myUniqueList = myList .toSet() .toList();console.log('myUniqueList', myUniqueList.toJS());// -> myUniqueList [ 1, 2, 3 ]
Using this approach, the set is an intermediary collection. Using sets ephemerally to enforce uniqueness is a common pattern in Immutable.js applications.
Read now
Unlock full access