Skip to Content
Mastering JavaScript Functional Programming
book

Mastering JavaScript Functional Programming

by Federico Kereki
November 2017
Intermediate to advanced
386 pages
9h 22m
English
Packt Publishing
Content preview from Mastering JavaScript Functional Programming

A handier implementation

Let's get ahead of ourselves. Doing FP doesn't mean always getting down to the very basic, simplest possible functions. For example, in the Converting to free point style section of Chapter 8, Connecting Functions - Pipelining and Composition, we will need a function to check if a number is negative, and we'll consider using binaryOp2() to write it:

const isNegative = curry(binaryOp2(">"))(0);

Never mind about the curry() function now (we'll get to it soon in Chapter 7, Transforming Functions - Currying and Partial Application) but the idea is that it fixes the first argument to zero, so our function will check, for a given number n, whether 0>n. The point here is that the function we just wrote isn't quite clear. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering JavaScript Functional Programming - Second Edition

Mastering JavaScript Functional Programming - Second Edition

Federico Kereki

Publisher Resources

ISBN: 9781787287440Supplemental Content