Compose
Understand how compose works in RamdaJS to combine functions from right to left. Learn to reverse operation order compared to pipe and grasp how this approach aligns with mathematical function composition.
We'll cover the following...
We'll cover the following...
If pipe made sense, you already know compose. Instead of going left-to-right, we go right-to-left.
This returns 49 since we’re using pipe.
But the same sequence with compose returns 162, since the order of operations have reversed.
To get 49, like pipe, flip the sequence.
compose mirrors the mathematical form of composition–the innermost function goes first.