methods of objects be called without bind?
Is there a way to call inc of obj without bind?
function callIt(callback){
callback();
}
var obj = {
count: 0,
inc: function(){
this.count++;
}
};
callIt(obj.inc.bind(obj));
obj.count;// 1
Question is relevant to me because of older IE-versions that do not support the method bind.
你可以使用一个函数值
callIt(function() { obj.inc(); });
链接地址: http://www.djcxy.com/p/94922.html
上一篇: jQuery使用哪个键码进行换码
下一篇: 对象的方法被调用时没有绑定?