Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created July 6, 2016 02:45
Show Gist options
  • Save codecademydev/49213cd7978c4917b369ea6989b940c3 to your computer and use it in GitHub Desktop.
Save codecademydev/49213cd7978c4917b369ea6989b940c3 to your computer and use it in GitHub Desktop.
Codecademy export
// here we define our method using "this", before we even introduce bob
var setAge = function (newAge) {
this.age = newAge;
};
// now we make bob
var bob = new Object();
bob.age = 30;
// and down here we just use the method we already made
bob.setAge = setAge;
// change bob's age to 50 here
bob.setAge(50);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment