re: What’s your favorite JS interview question? VIEW POST

TOP OF THREAD FULL DISCUSSION
re: What will be output of (() => console.log(this)).bind("done")() var fx = (() => console.log(this)); fx.call("done"); Try in chrome,...
 

Great question! I believe this is because arrow functions can't be bound and also don't have arguments, for that we need to use regular function definitions:

(function() { console.log(this) }).bind("done")();

var fx = (function() { console.log(this) });
fx.call("done");

(function() { console.log(arguments) })("a");
 

You can't bind anything to an arrow functions this. But you can bind arguments to them. ie:

((arg) => console.log(arg)).bind(null, "done")()

would work.

code of conduct - report abuse