Skip to content
Onsite

Output: fn.bind(a).bind(b)() logging this.name

MediumP2Output

What does this code print?

1function show() {
2 return this.name;
3}
4const a = { name: 'a' };
5const b = { name: 'b' };
6
7const bound = show.bind(a).bind(b);
8console.log(bound());
9console.log(show.call(b));
10console.log(show.bind(a).call(b));
Saved automatically

One line per console.log. Arrays as [1, 2, 3], objects as { a: 1 }, an uncaught error as Uncaught TypeError: message (Chrome and Node wording).

Hints

Saved automatically