Created
October 31, 2014 06:14
-
-
Save TessMyers/31aaf38de1de4b9be40a to your computer and use it in GitHub Desktop.
Revisions
-
TessMyers created this gist
Oct 31, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ // This function does not return anything, but instead creates a new instance of an object with // the given attributes when the "new" keyword is used. var Cat = function(){ this.stomach = []; }; // adds methods to the prototype for this new cat object Cat.prototype.meow = function(){ console.log("MEOWPURR"); }; Cat.prototype.eat = function(food){ this.stomach.push(food); }; // make that kitty var kitty = new Cat(); kitty.meow(); // "MEOWPURR" kitty.eat('tiny helpless birds'); console.log(kitty.stomach) // ["tiny helpless birds"]