So, this
is a weird concept in Javascript. this
merely refers to the calling context at any given point. Which means that if you define function hai(isGenuine: boolean) { ... }
...and you call hai(true);
, depending on where you call it this
may or may not actually refer to your class.
For example, If you were to dosetTimeout(function() { hai(false); }, 1000};
this
would refer to the window
object. Which of course is not what you want.
So, then Typescript comes along and starts introducing classes, and says hey..."this
" whole thing has become a problem. So they introduce fat arrows, which in short properly maintains the concept of this
to always refer to your class. Even if you dosetTimeout(() => { hai(false; }, 1000};
this
will still refer to your class.
Hopefully that makes sense. I don't feel like I've gotten any better conveying all of this in a succinct and explanatory manner .
For more information you can look here: Arrow Functions.