DEV Community

Discussion on: Master ‘this’ in JavaScript

Collapse
 
polymathsomnath profile image
Somnath Singh

Namaste @lukeshiru
Thank you so much for your response.
Avoiding this in JavaScript is very much possible.

In 2007, there were several research projects that were trying to develop a secure subset of JavaScript. One of the biggest problems was the managing of this. In a method call, "this" is bound to the object of interest, which is sometimes good thing. But if that same function object is called as a function, then "this" could be bound to the global object, which was a very bad thing. They obliterated "this" completely and found that it was not only easier to write code but it was also more cleaner and the language still remained Turing Complete.

I covered that story and how major frameworks like React are getting away from the usage from "this" but the article got quite big, So I edited it out.
Sometimes you have to do the hard things and cut the best parts out and say only what is needed. As the article was on removing the fear that developers have while using "this" keyword, adding anything more made it look tedious.

Writing code in JavaScript without using "this" is a topic by itself and can be covered in a separate article.

I may consider it writing in the future!
Take care, see you in my other post! 🙂