January 2020
Intermediate to advanced
470 pages
11h 13m
English
Let's consider the filter() method from Chapter 5, Programming Declaratively – A Better Style. Given a predicate, we can filter the array to only include those elements for which the predicate is true. But how would you do a reverse filter and exclude the elements for which the predicate is true?
The first solution should be pretty obvious: rework the predicate so that it returns the opposite of whatever it originally returned. In Chapter 5, Programming Declaratively – A Better Style, we looked at the following example:
const delinquent = serviceResult.accountsData.filter(v => v.balance < 0);
So, we could just write it the other way round, in either of these two equivalent fashions. Note the different ways of ...
Read now
Unlock full access