Skip to content

Instantly share code, notes, and snippets.

@joepie91 joepie91/.js

Last active Aug 29, 2015
Embed
What would you like to do?
`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
You can’t perform that action at this time.