组合 Composition
组合某种类型(含函数)的两个元素,进而生成一个该类型的新元素:
Javascr ipt
let compose = (f, g) => a => f(g(a))
let toUpperCase = x => x.toUpperCase()
let exclaim = x => x + '!'
let shout = compose(exclaim, toUpperCase);
shout("hello world") // HELLO
事件委托的封装
function eveEnt(child,cb){
return function(eve){
var e = eve || window.event;
var mubiaoEle = e.target || e.srcElement;
for(var i = 0;i<child.length;i++){
if(child[i]==mubiaoEle){
cb.bind(mubiaoEle)();
}
}
}
}