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

15 lines
389 B
Markdown

The answer: **John**.
```js run no-beautify
function f() {
alert(this.name);
}
f = f.bind( {name: "John"} ).bind( {name: "Pete"} );
f(); // John
```
The exotic [bound function](https://tc39.github.io/ecma262/#sec-bound-function-exotic-objects) object returned by `f.bind(...)` remembers the context (and arguments if provided) only at creation time.
A function cannot be re-bound.