en.javascript.info/1-js/06-advanced-functions/10-bind/3-second-bind/solution.md
2017-05-12 10:28:56 +02:00

389 B

The answer: John.

function f() {
  alert(this.name);
}

f = f.bind( {name: "John"} ).bind( {name: "Pete"} );

f(); // John

The exotic bound function object returned by f.bind(...) remembers the context (and arguments if provided) only at creation time.

A function cannot be re-bound.