September 2017
Intermediate to advanced
216 pages
6h 8m
English
Strict equality is used when you're looking for a value in a collection, and you have something with which you can compare it. For example, you could define a filter function that uses strict equality to look for values that equal 1 or 2, as follows:
const filter = i => i === 1 || i === 2;
You can then pass this function to the filter() method of a list:
const myList = List.of(1, 2, 3);const myFilteredList = myList.filter(filter);console.log('myList', myList.toJS());// -> myList [ 1, 2, 3 ]console.log('myFilteredList', myFilteredList.toJS());// -> myFilteredList [ 1, 2 ]
You can use the same function to filter maps, as shown here:
const myMap = Map.of( 'one', 1, 'two', 2, 'three', 3);const myFilteredMap = myMap.filter(filter); ...
Read now
Unlock full access