Skip to content

Instantly share code, notes, and snippets.

@mannharleen
Created June 4, 2020 06:47
Show Gist options
  • Select an option

  • Save mannharleen/87ee0fafb8f4926b1318c88c5a8e3dff to your computer and use it in GitHub Desktop.

Select an option

Save mannharleen/87ee0fafb8f4926b1318c88c5a8e3dff to your computer and use it in GitHub Desktop.
const myObject = {
myArrowFunction: null,
myMethod: function () {
this.myArrowFunction = () => { console.log(this) };
}
};
myObject.myMethod() // this === myObject
myObject.myArrowFunction() // this === myObject
const myArrowFunction = myObject.myArrowFunction;
myArrowFunction() // this === myObject
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment