Skip to content

Instantly share code, notes, and snippets.

@fhsinchy
Created May 27, 2020 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fhsinchy/85073405379940ff71b7153059a52212 to your computer and use it in GitHub Desktop.
Save fhsinchy/85073405379940ff71b7153059a52212 to your computer and use it in GitHub Desktop.
let globalThis = this;
let obj1 = {
innerMethod: function() {
console.log('Global This: ', globalThis);
console.log('Local This: ', this);
console.log('Are they same?', globalThis === this);
console.log('Is this the object?', obj1 === this);
}
};
obj1.innerMethod();
// Global This: Window
// Local This: Object { innerMethod: innerMethod() }
// Are they same? false
// Is this the object? true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment