Repository for learning functional programming with JS.
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
- Pure functions
- Immutability
- Functions as first-class entities
- Higher-order functions
What does make a function pure?
- Deterministic: It returns the same result if given the same arguments.
- There are not side effects Tips:
- Any function that relies on a random number generator can not be pure.
- Presence of const key word.
- It returns someting instead of just cause some side effect like console.
When data is immutable, its state can not change after itโs created. If you want to change an immutable object, you canโt. Instead, you create a new object with the new value.
- You can refer to it from constants and variables
- You can pass it as a parameter to other functions
- You can return it as result from other functions
It means a function that either:
- takes one or more functions as arguments, or
- returns a function as its result Examples:
- Map
- Filter
- Reduce
Cya, folks! I hope we all learn together ๐