One JavaScript concept that confused me for a long time is the concept of this . At first, it looks simple. But while using inside a function, the behavior changes based on how the function is called. It works differently in : Normal function Object Method Arrow Function Normal Function In a normal function, this usually refers to the global object or undefined in strict mode. Example: function test () { console . log ( this ); } Enter fullscreen mode Exit fullscreen mode The output will show window in a non-strict mode and undefined in a strict mode. Object Method When a function is called as a method of an object, the this keyword refers to the object that is calling the method. Example: const user = { name : " Swarnali " , Name () { console . log ( this . name ); } }; user . Name (); //Output : Swarnali Enter fullscreen mode Exit fullscreen mode In user.Name() , the object (user) before the dot(.) becomes the value of this inside the function. That is why this.name accesses user.name .…