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

Memoizing

Back in Chapter 4, Behaving Properly - Pure Functions, we considered the case of the Fibonacci function and saw how we could transform it, by hand, into a much more efficient version by means of memoization: caching calculated values, to avoid recalculations. For simplicity, let's now only consider functions with a single, non-structured parameter, and leave for later functions with more complex parameters (objects, arrays) or more than one parameter for later.

The kind of values we can handle with ease are JS's primitive values: data that isn't objects and has no methods. JS has six of these: boolean, null, number, string, symbol, and undefined. It's likely we would only see the first four as actual arguments. See more in https://developer.mozilla.org/en-US/docs/Glossary/Primitive ...
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