From You don't know JS - this & Object prototypes, by Kyle Simpson, page 32, heading Lexical this:
function foo() {
return (a) => {
console.log(this.a);
};
}
var obj1 = {
a:2
}
var obj2 = {
a:3
}
var bar = foo.call(obj1);
bar.call(obj2); // 2, not 3!
The point here is that this returned arrow function will inherit the lexical this from function foo.
What I do not understand is why the input for this arrow function above is a
?
What is the point of having 'a' as the input to the arrow function?
What is the point of having 'a' as the input to the arrow function?
As you said, it is a variable declaration that is never used.
It is pointless.
ESLint reports:
'a' is defined but never used. (no-unused-vars)