Middle
```javascript const obj = { name: 'Alex', say() { console.info(this.name); } }; const obj2 = { name: 'Ivan' } const fn = obj.say.bind(obj).bind(obj2); fn(); obj.say(); ```
sobes.tech AI
Answer from AI
In this code, the say function is doubly bound to different contexts using bind:
const fn = obj.say.bind(obj).bind(obj2);
However, the bind method returns a new function with a fixed context (this). Calling bind again on an already bound function does not change the context — it remains as initially set.
Therefore:
fn()will outputAlex, because the firstbind(obj)fixedthistoobj.obj.say()will outputAlex, because it is called directly onobj.
Conclusion:
Alex
Alex
This demonstrates that bind cannot be overridden by re-binding.