2

Thinking Functionally – A First Example

In Chapter 1, Becoming Functional, we went over what FP is, mentioned some advantages of applying it, and listed some tools we’d need in JavaScript. For now, let’s leave the theory behind and start by considering a simple problem and how to solve it in a functional way.

In this chapter, we will do the following:

  • Look at a simple, e-commerce-related problem
  • Consider several usual ways to solve it (with their associated defects)
  • Find a way to solve the problem by looking at it functionally
  • Devise a higher-order solution that can be applied to other problems
  • Work out how to carry out unit testing for functional solutions

In future chapters, we’ll be returning to some of the topics listed here, so we won’t ...

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.