Skip to content

Instantly share code, notes, and snippets.

@kristyburge
Created July 30, 2018 18:04
Show Gist options
  • Save kristyburge/76f7b6820240abeffdd0469127105eed to your computer and use it in GitHub Desktop.
Save kristyburge/76f7b6820240abeffdd0469127105eed to your computer and use it in GitHub Desktop.
When 'this' is used inside an object, it points to the object itself
var dog = {
name: 'Chester',
breed: 'beagle',
intro: function(){
console.log(this);
}
};
dog.intro();
// returns the dog object and all of it's properties and methods
// {name: "Chester", breed: "beagle", intro: ƒ}
// breed:"beagle"
// intro:ƒ ()
// name:"Chester"
// __proto__:Object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment