I\'m just starting to research different programming styles (OOP, functional, procedural).
I\'m learning JavaScript and starting into underscore.js and came along this s
FP
In FP, a function takes inputs and produces output with the guarantee that the same inputs will yield the same outputs. In order to do this, a function must always have parameters for the values it operates on and cannot rely on state. Ie, if a function relies on state, and that state changes, the output of the function could be different. FP avoids this at all costs.
We'll show a minimum implementation of map
in FP and OOP. In this FP example below, notice how map
operates only on local variables and does not rely on state -