One feature of ES2015 that I feel can be a stumbling block (but extremely useful) is Arrow Functions lexical scoping of
Before this addition, every new function defined its own
this - meaning we were required to explicitly bind or locally store the
this reference that we desired in many use-cases.
The two technique used to overcome this problem are highlighted below, using a locally stored
this reference or a bound function.
The contrived example usage below shows passing the counters
inc method to a high-order function and asserting the desired
With the introduction of Arrow functions, the
this value is instead captured based on the enclosing context, resulting in more readable code.