4

Behaving Properly – Pure Functions

In Chapter 3, Starting Out with Functions, we considered functions as the critical elements in functional programming (FP), went into detail about arrow functions, and introduced some concepts, such as injection, callbacks, polyfilling, and stubbing. In this chapter, we’ll have the opportunity to revisit or apply some of those ideas.

In this chapter, we will do the following:

  • Consider the notion of purity and why we should care about pure functions—and impure functions as well!
  • Examine the concept of referential transparency
  • Recognize the problems implied by side effects
  • Show some advantages of pure functions
  • Describe the main reasons behind impure functions
  • Discover ways to minimize the number of impure ...

Get Mastering JavaScript Functional Programming - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.