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(); });
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.