Files
30-seconds-of-code/snippets/negate.md
Angelos Chalaris 0425ebefe7 Archive, multitagging, cleanup
Cleaned up the current snippets for consistency and minor problems, added multiple tags to most of them, archived a few.
2018-01-05 16:33:54 +02:00

286 B

negate

Negates a predicate function.

Take a predicate function and apply the not operator (!) to it with its arguments.

const negate = func => (...args) => !func(...args);
filter([1, 2, 3, 4, 5, 6], negate(isEven)); // [1, 3, 5]
negate(isOdd)(1); // false