September 2017
Intermediate to advanced
216 pages
6h 8m
English
Another type of simple comparison that you might want to perform when filtering collections is greater than or less than. Once again, this is done in the callback function that's passed to the filter() method:
const myList = List.of(1, 2, 3);const myMap = Map.of( 'one', 1, 'two', 2, 'three', 3);const myFilteredList = myList.filter(i => i < 3);const myFilteredMap = myMap.filter(i => i > 1);console.log('myList', myList.toJS());// -> myList [ 1, 2, 3 ]console.log('myFilteredList', myFilteredList.toJS());// -> myFilteredList [ 1, 2 ]console.log('myMap', myMap.toJS());// -> myMap { one: 1, two: 2, three: 3 }console.log('myFilteredMap', myFilteredMap.toJS());// -> myFilteredMap { two: 2, three: 3 }
You can filter either ...
Read now
Unlock full access