Code Fellows Notes
An arrow function expression is a compact alternative to a traditional function expression, but is limited and can’t be used in all situations.
There are differences between arrow functions and traditional functions, as well as some limitations:
Additional Resources:
Can I Use? JavaScript Arrow Functions by Wes Bos
CAVEATS
this
context is not reset within an arrow function.The value of this
is therefore the same as the this
of the enclosing scope (the surrounding non-arrow function). If there isn’t a non-arrow function scope surrounding, the this context will be, in the browser, the global window object.
this
value of the enclosing functional scope. Therefore, you will want to avoid using an arrow function in a constructor (where we need the contextual this
to be the object we are building) or any method that needs to use this
to behave properly.