Sometimes I thought that was this, but this turned out to be something else entirely. I learned this is not assigned a value until its containing function is invoked. Whatever object invokes the function containing this becomes this.

In the global scope, this refers to the window object. However, when strict mode is enabled, this is assigned undefined in global functions and in anonymous functions not bound to an object.

var subject = 'Yo mama';
var joke = 'got the wooden leg with real feet';

function makeJoke() {
  console.log(this.subject + ' ' + this.joke);
};

var obj = {
  subject: 'Yo mama',
  joke: 'got an afro with a chin strap',
  makeJoke: function() {
    console.log(this.subject + ' ' + this.joke);
  }
} ;

makeJoke(); // Yo mama got the wooden leg with real feet
window.makeJoke(); // same thing as above since makeJoke() is defined globally and window is the invoker
obj.makeJoke(); // Yo mama got an afro with a chin strap

In the example, makeJoke() and window.makeJoke() are equivalent. window is the invoker, so this is assigned to window. obj.makeJoke() on the other hand has obj as the invoker, so this is assigned to obj. Next time, I’ll take a look at common cases where this is misunderstood and pulls some trick-tronkory.