HELP: Converting this arrow function...

Hi, Im tryng to convert arrow functions to regular ones and viceversa just to understand them 100%.

But I cant make my code work this one:

Code:
setTimeout(() => this.colorOff(color), 350)

I converted to:

Code:
setTimeout(function () {
  this.colorOff(color);
}, 350);

The arrow function works but not the regular one...
Arrow functions are nice because they remove the complexity of the this object. When you create a regular function instead, the value of this is different than when you create an arrow function.
The fix for you would be:

Code:
var that = this;
setTimeout(function () {
  that.colorOff(color);
}, 350);
I see....
So, whenever Im converting arrow to regular functions I need to consider that if the keyword "this"is being used, I need to declare a variable = this first because "this" is not binded to the object?
Yes, basically when you declare a new function, the "this" object will refer to that function. This used to cause a lot of unnecessary issues so when they added arrow functions, they made it keep the parent value of "this"

Original thread: https://forums.rpgmakerweb.com/threads/help-converting-this-arrow-function.116145/