what it evaluates to depends on where it is used. When used outside any function, in global space, this refers to the enclosing object, which in this case is the enclosing browser window, the window object. When used in a function defined in the global space, what the keyword this refers to depends on how the function is called. When such a function is called directly (e.g. f(x)), this will refer back to the global space in which the function is defined, and in which other global functions and variables may exist as well (or in strict mode, it is undefined). If a global function containing this is called as part of the event handler of an element in the document object, however, this will refer to the calling HTML element. When a method is called using the new keyword (e.g. var c = new Thing()) then within Thing this refers to the Thing object itself. When a function is attached as a property of an object and called as a method of that object (e.g. obj.f(x)), this will refer to the object that the function is contained within. It is even possible to manually specify this when calling a function, by using the .call() or .apply() methods of the function object. For example, the method call obj.f(x) could also be written as obj.f.call(obj, x). To work around the different meaning of this in nested functions such as DOM event handlers, it is a common idiom in JavaScript to save the this reference of the calling object in a variable (commonly called that or self), and then use the variable to refer to the calling object in nested functions. For example: // In this example $ is a reference to the jQuery library $(".element").hover(function() { // Here, both this and that point to the element under the mouse cursor. var that = this; $(this).find('.elements').each(function() { // Here, this points to the DOM element being iterated. // However, that still points to the element under the mouse cursor. $(this).addClass("highlight"); }); }); Notably, JavaScript makes use of both this and the related keyword self (in contrast to most other languages which tend to employ one or the other), with self being restricted specifically to web workers. Finally, as a reliable way of specifically referencing the global (window or equivalent) object, JavaScript features the globalThis keyword. Lua In Lua, self is created as