Let's say there are two functions.
function foo(callback) {
...
}
function bar() {
...
}
What's the difference when I call foo(bar)
and foo(() => bar())
by assuming bar requires no parameters?
I recently former one occurs error regarding this
context, while second one works just fine. I know arrow function binds this
context into the function, I have no idea what's the difference.
FYI, here is the code with issue.
socket.disconnect(socket.connect); // line 1
socket.disconnect(() => socket.connect()); // line 2
socket.disconnect(function() { socket.connect(); }); // line 3
I just found that the problem might not be related to the context. It might be something with apply or bind. Because line2 and line 3 works fine, while only line 1 shows error.