Why is “this” in an ES6 class not implicit?

社会主义新天地 提交于 2019-12-01 15:53:21
marknorkin

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!