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

Partial application with eval()

If we want to be able to do partial application fixing any combination of parameters, we must have a way to specify which arguments are to be left free and which will be fixed from that point on. Some libraries, such as Underscore or LoDash, use a special object, _, to signify an omitted parameter. In this fashion, still using the same nonsense() function, we would write the following:

const fix2and5 = _.partial(nonsense, _, 22, _, _, 1960);

We could do the same sort of thing, by having a global variable that would represent a pending, not yet fixed argument, but let's make it simpler, and just write undefined to represent a missing parameter.

When checking for undefined, remember to always use the === operator; ...
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