Concepts of Functional Programming in Javascript
Functional Programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data
Pure Functions:
- return the same result if given the same arguments
- do not cause observable side effects
Immutable Dat:
- unchanging over time
- unable to be changed after it is created
Pure functions + Immutable Data = Referential Transparency
Referential Transparency:
- consistently yielding the same result for the same input
Functions as First Class Entities:
- functions are also treated as values and used as data
Higher-Order Functions:
-take one or more functions as arguments OR
- return a function as its result
Refactoring JavaScript for Performance and Readability (with Examples!)
hash function is used to map a given key to a location in the hash table
Strategies for easier to read code:
- Return early from functions
- Cache variables so functions can be read like sentences -Check for Web APIs before implementing your own functionality