Why Is "this" In An ES6 Class Not Implicit?
I know that ES6 solved a lot of problems that existed with the this keyword in ES5, such as arrow functions and classes. My question relates to the usage of this in the context of
Solution 1:
Maybe I will not directly answer your question, but I'll try to direct the way you should think about JS class
keyword.
Under the cover there is no magic about it. Basically it's a syntatic sugar over prototypal inheritance that was since the beginning of JavaScript.
To read more about classes in JS click here and here.
As of why you need explicitly write this
is that because in JS it's always context sensitive, so you should refer to exact object. Read more.
Post a Comment for "Why Is "this" In An ES6 Class Not Implicit?"