April 2018
Beginner
536 pages
13h 21m
English
FP introduces some concepts and principles that will help us to improve the predictability of our code. Let's look at one of these core concepts: pure functions.
A function can be considered pure when it returns a value computed using only the arguments passed to it. Also, a pure function avoids mutating its arguments or any other external variables. As a result, a pure function always returns the same value given the same arguments, independently of when it is invoked.
The isIndexPage function declared in the preceding section is not a pure function because it accesses the pathname variable and it has not been passed as an argument to the function. We can transform the preceding function into a pure function by rewriting it ...