Read: 09 Refactoring from article "Concepts of Functional Programming in Javascript" - cindyweiss/seattle-301d55 GitHub Wiki
What is functional programming?
Functional programming is a programming paradigm โ a style of building the structure and elements of computer programs โ that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data โ Wikipedia
The first fundamental concept we learn when we want to understand functional programming is pure functions.
Here is a very strict definition of purity:
It returns the same result if given the same arguments (it is also referred as deterministic) It does not cause any observable side effects.
Reading Files
If our function reads external files, itโs not a pure function โ the fileโs contents can change.
Random number generation
Any function that relies on a random number generator cannot be pure.
It does not cause any observable side effects
Examples of observable side effects include modifying a global object or a parameter passed by reference.