Member-only story
The Magic Of this Keyword
JavaScript borrows this keyword from C++, where it is used to point to an instance of an object from within its own class definition. There is absolutely no confusion about this keyword in C++ because this keyword is never used for any other intent than to point to an instance of an object from its constructor!
Here’s a list of my best web development tutorials.
Complete CSS flex tutorial on Hashnode.
Ultimate CSS grid tutorial on Hashnode.
Higher-order functions .map, .filter & .reduce on Hashnode.
Follow me @ Twitter, Instagram & fb to never miss premium articles.
The original designer of JavaScript decided to tie a secondary feature to this keyword. Not only is it used to point to an instance of an object from its own constructor or its methods (hence, this) it is also used to keep track of execution context — which is often based on where a function was called from.
This duality of this keyword is exactly what have wrecked havoc on learning and…