不能。bind 返回的绑定函数其 this 值在创建时已被固化([[BoundThis]] 内部槽固定),后续 call 或 apply 无法覆盖,属于硬绑定,优先级高于临时绑定。

不能。用 bind 绑定过的函数,其 this 是永久绑定的,后续调用 call 或 apply 无法覆盖它。
为什么 bind 后 call 无效?
bind 返回的是一个“绑定函数(bound function)”,根据 ECMAScript 规范,它的 this 值在创建时就被固化([[BoundThis]] 内部槽已设定),无论后续如何用 call、apply 或直接调用,都不会改变这个值。
简单说:bind 是“硬绑定”,优先级高于 call/apply 的临时绑定。
实际例子验证
function greet() {
return `Hello, ${this.name}`;
}
const obj1 = { name: 'Alice' };
const obj2 = { name: 'Bob' };
const bound = greet.bind(obj1);
console.log(bound()); // "Hello, Alice"
console.log(bound.call(obj2)); // 还是 "Hello, Alice",不是 Bob
console.log(bound.apply(obj2)); // 同样是 "Hello, Alice"
如果真需要动态改 this,怎么办?
有几种替代方案:
立即学习“Java免费学习笔记(深入)”;
-
不用 bind,改用闭包或箭头函数封装逻辑:把需要的上下文作为参数传入,而非依赖
this; -
用普通函数 + call/apply 显式调用:避免提前 bind,留到执行时再控制
this; -
重新 bind(覆盖原绑定):对已 bind 的函数再次调用
bind,会生成新函数并绑定新this(但注意这不会修改原 bound 函数); - 用 Function.prototype.bind.call 来绕过?不行:因为 bind 返回的函数本身不接受外部 this 覆盖,强行 call 仍无效。
小结
bind 是单向、不可逆的 this 锁定机制。想保留灵活性,就别过早 bind;若已 bind 又需换上下文,唯一办法是放弃该 bound 函数,换一种不依赖 this 绑定的设计方式,比如传参或使用 class 实例方法。


















