1By respecting these restrictions,
2FP aims to write code that is clearer to understand and more bug resistant.
3This is achieved by avoiding using flow-control statements
4(for, while, break, continue, goto) which make the code harder to follow.
5 requires us to
6write pure, deterministic
7functions which are less likely to be buggy.
1const myResult = f1( f2(data) ); // composition: pass the output DATA of one function to the input of another ... like pipes.
2function add(a){return function(b){return a + b} } // functional composition
3add(2)(3) //-> 5