compose函数第二步

我们要先计算a函数,依赖a函数返回的结果在计算b函数
举例:

	let a = (x,y)=>x+y;
    let b = (m)=>m * m;

第一种:

let q1 =function  compose(a,b){
	return (x,y) => b(a(x,y))
} 

第二种:

    function q (...[first,...out])=>(...args)=>{
				let ret = first(...args);
				if(!fn){
				return 
				}
			out.forEach(fn=>{
					ret = fn(ret)
			})
	}

你可能感兴趣的:(compose函数第二步)