JS Arrow Function ‘this’ Binding
Arrow functions create a permanent link to the surrounding lexical scope through a mechanism called “lexical this
”.
- They form a closure over the current scope, including the value of
this
.
Example:
regularMethod
loses itsthis
context when assigned to a variable.arrowMethod
retains itsthis
context because it was bound to the instance when the arrow function was created.