其他分享
首页 > 其他分享> > pipe简单理解

pipe简单理解

作者:互联网

const addOne = x => x+1
const addTwo = x => x+2
addTwo(addOne(5)) //8
const pipe = (fn1,fn2) => x => fn2(fn1(x))
pipe(addOne,addTwo)  //x => fn2(fn1(x))
pipe(addOne,addTwo)(5) //8
const mergeFn = pipe(addOne,addTwo) 
mergeFn(5) //8

 

标签:fn2,fn1,mergeFn,addOne,addTwo,pipe,理解,简单
来源: https://www.cnblogs.com/oliverYan/p/15801180.html