
Understanding "this" in JS
this keyword in JS can be trickier to understand at first glance. The obvious reason could be the way the this keyword behaves in JavaScript is different when compared to its peer languages like C++, Java, etc But to be honest, understanding the this keyword in JavaScript is actually easier than it looks. There are some fixed sets of rules provided by ECMA . So if we understand those rules, the this keyword is done and dusted . By the end of this post, I assure every reader will gain complete knowledge of the this keyword in JavaScript and will be able to use the this keyword more confidently in their projects. Now starting, before actually diving into the this keyword and understanding its behavior, we have to know a few prerequisites , and these prerequisites would majorly clear a lot of dust around the this keyword in JS. Prerequisites: The this keyword has a valid meaning only inside an execution context . Now what does that mean? JS has primarily 2 execution contexts defined in th
Continue reading on Dev.to JavaScript
Opens in a new tab


