Over the years, I’ve seen a lot of confusion about JavaScript function invocation. In particular, a lot of people have complained that the semantics of this in function invocations is confusing. In my opinion, a lot of this confusion is cleared up by understanding the core function invocation primitive, and
Do people still use this
for functions? I’ve been in typescript for years, its all arrow functions and very few classes in our codebase. There are almost no this
at all. Is it still comnon in js?
this
is very handy when you want to carry over some shared context. Justin Fagnani described this
as an implicit first argument, which is a model that helped me understand how to use it better.