In a previous question, I was encouraged to ask this follow up: What difference does it make to wrap a function some.func
into something like (arg) => some.func(arg)
if I know that some.func
only takes one argument?
As a concrete example: In my other question I observed a surprising difference between using
.on("mouseover", tip.show)
versus
.on("mouseover", (d) => tip.show(d))
In this case the first version did have the expected behavior, while the second version was behaving differently (see jsfiddle of other question). The reason here was that I accidentally made tip
a global.
The more general question: Why do they behave differently in the first place?