function bindThis(f, oTarget) { return f.bind(oTarget); }
// apply function bindThis(f, oTarget) { return function() { return f.apply(oTarget, arguments); } } // call function bindThis(f, oTarget) { return function() { return f.call(oTarget, ...arguments); } } // bind function bindThis(f, oTarget) { return f.bind(oTarget); }没有提词器不觉得很扯吗?
function bindThis(f, oTarget) { return f.bind?f.bind(oTarget):function(){return f.apply(oTarget,arguments)} }如果有bind函数直接调用,没有调用call和apply函数进行绑定,因为立即调用缘故采用匿名函数封装,call写法:
function bindThis(f, oTarget) { return f.bind?f.bind(oTarget):function(){return f.apply(oTarget,..arguments)} }