Converting to pointfree style

On the other hand, you had better pause for a minute and try not to write everything in pointfree code, whatever it might cost. For example, consider the isNegativeBalance() function we wrote back in Chapter 6, Producing Functions – Higher-Order Functions:

const isNegativeBalance = v => v.balance < 0;

Can we write this in a pointfree style? Yes, we can, and we'll see how—but I'm not sure we'd want to code this way! We can consider building a pipeline of two functions: one will extract the balance from the given object, while the other will check whether it's negative. Due to this, we will write our alternative version of the balance-checking function like so:

const isNegativeBalance2 = pipeline(getBalance, isNegative); ...

Get Mastering JavaScript Functional Programming - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.