Functional programming is programming paradigms where we take care of multiple things like:
- Each operation decomposes into multiple functions. For example, a Function should perform one task.
- Function should be pure and will always take input and give an output.
- Side effects operation should be encapsulated into another function that is only responsible to handle/perform side effects and should be not mixed with regular operations.
- Immutability, where the function should not change the global data or passed references of arrays and objects (non-primitive values). Instead, make a copy of that data and use it. Like map, filter, and forEach higher-order function.
- Function composition, where one function output becomes the output of another function.
Top comments (2)
Would you mind sharing some examples about how these concepts have helped you write better code? I do agree they are powerful concepts!
Sure, I will add some code example's for each point