Issues with "this" scope in embedded functions and = operator being the solution - sindat/Furcifer GitHub Wiki
The this
has a different scope in embedded functions, mostly callbacks.
That's why I was getting undefined
when I tried to pull class variable values using this
.
The solution is to reference this
using a variable in the appropriate scope ( var self = this
), OR USE ARROW FUNCTIONS.
Arrow functions =>
do not bind their own this
scope, unless specified I guess.
Therefore, I will not be encountering the this
reference issue with them. Use arrow functions all the time.