I need help understanding the rest and spread operator

Viewed 812

This is the code:

const Pipe = (...fns) => fns.reduce((f,g) => (...args) => g(f(...args)));

So by (...fns) the fns arguments becomes an array right? in this part:

 (f,g) => (...args)

where did args came from? is there a default args parameter? and I cannot read this part:

(...args) => g(f(...args))

I just cannot wrap my head with this nesting and what reduce does here is so confusing.

3 Answers
Related