DEV Community

Discussion on: What Can Array Folding Do?

Collapse
 
mebble profile image
Neil Syiemlieh • Edited

The pipe takes in an array of functions and "connects" them so that the output of a function within that array is passed as an input to the function after it.

// 
const squareThenIncrement = pipe([x => x * x, x => x + 1])
squareThenIncrement(4);  // 17
squareThenIncrement(9);  // 82

There are a few medium articles out there explaining it in more detail. I didn't want to make this post too detailed. I just wanted to show how much we could do using just that fold function