Skip to content

Instantly share code, notes, and snippets.

@joepie91
Last active August 29, 2015 14:23
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 joepie91/22fb5cd443517566412b to your computer and use it in GitHub Desktop.
Save joepie91/22fb5cd443517566412b to your computer and use it in GitHub Desktop.
`this` keyword in Javascript
function doThing() {
console.log("Name:", this.name);
}
a = {name: "Joe", doThing: doThing};
b = {name: "Bill", doThing: doThing};
a.doThing(); // Name: Joe
b.doThing(); // Name: Bill
doThing(); // Name: undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment