November 2017
Intermediate to advanced
386 pages
9h 22m
English
If you wanted, you could also define .none(), as the complement of .every() -- this new function would be true only if none of the elements of the array satisfied the given predicate. The simplest way of coding this would be by noting that if no elements satisfy the condition, then all elements satisfy the negation of the condition.
const none = (arr, fn) => arr.every(v => !fn(v));
If you want, you can turn it into a method, by modifying the array prototype, as we earlier saw -- it's still a bad practice, but it's what we have until we start looking into better methods for composing and chaining functions, as in Chapter 8, Connecting Functions - Pipelining and Composition.
Array.prototype.none = function(fn) { return ...