【发布时间】:2015-04-08 11:09:40
【问题描述】:
bind 方法不会将 't' 变量作为新的 'this' 关键字传递给“ob.bind_part()” 对象字面量函数吗?
var ob = {
"first": function() {
console.log("first function");
var t = "new bind";
ob.bind_part.bind(t);
},
"bind_part": function() {
console.log(this.toString());
}
};
(function() {
ob.first();
ob.bind_part(); // returns the 'ob' object instead of the bind
})();
但是,如果使用“调用”而不是绑定
ob.bind_part.call(t); //THIS WORKS
有效吗?
知道为什么绑定不起作用吗?
谢谢
【问题讨论】:
标签: javascript bind