You have created a
See the example below and what the problem is about to become much more clear.
The issue is that the Lambda captures "this" in a different way than the anonymous function (). This is actually clearly documented under the Arrow Functions section in the Mozilla MDN page.
But if you are like me it is much easier to understand by actually coding the situation.
The Explanation of The Example:
I have created a simple Main class in which a callback "
If you are not aware of all of the implications of this, you would (and I have) thought that the class member property "s" should be accessible from within the callback in all of the scenarios.
The ones that works are;
- If the callback function is is a function
() and not an arrow function like =>(). This will not work.
- Also, you can try this yourself, any attempt to pass "this" as
mainlike Apply, Call or Bind to the lambda function will have no effect.