Sobes.tech
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 output Alex, because the first bind(obj) fixed this to obj.
  • obj.say() will output Alex, because it is called directly on obj.

Conclusion:

Alex
Alex

This demonstrates that bind cannot be overridden by re-binding.

```javascript const obj = { name: 'Alex', say() {… - sobes.tech