January 2020
Intermediate to advanced
470 pages
11h 13m
English
Let's end this section by considering an important question: can you ensure that a function is actually pure? To show the difficulties of this task, we'll go back to the simple sum3() function that we saw in the Spread section of Chapter 1, Becoming Functional – Several Questions, just rewritten to use arrow functions for brevity. Would you say that this function is pure? It certainly looks like it!
const sum3 = (x, y, z) => x + y + z;
Let's see: the function doesn't access anything but its parameters, doesn't even try to modify them (not that it could (or could it?)), doesn't perform any I/O, or work with any of the impure functions or methods that we mentioned earlier. What could go wrong?
The answer has to do with ...
Read now
Unlock full access