3种方式
1.loop
take a set of functions,make it into an array ,you loop over that array,
each time you call a function you capture the result and that becomes the input of the next
2.recursion
3.reduce
pipe 实现
形如 pipe(f1,f2,f3)(4) 被执行为 f1(f2(f3(4)))
function pipe(...fns) {
return function piped(result){
var list = [...fns];
while (list.length > 0) {
// take the first function from the list
// and execute it
result = list.shift()( result );
}
return result;
};
}
这里