DEV Community

Discussion on: What’s your favorite JS interview question?

Collapse
themindfuldev profile image
Tiago Romero Garcia • Edited on

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");
Collapse
misterwhat profile image
Jonas Winzen

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.

Thread Thread
themindfuldev profile image
Tiago Romero Garcia

Oh nice! Thanks for explaining that.