Created
January 4, 2015 01:45
-
-
Save pr00thmatic/6673196e840102c7874a to your computer and use it in GitHub Desktop.
finding an instance safe way to achieve this: https://gist.github.com/donburks/6e266289fa29735bcad2
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 characters
var Cat = { // this is actually an object: a "prototype" object | |
color: 'none', | |
size: 'none', | |
meow: function() { | |
console.log("meow"); | |
} | |
}; | |
var Garfield = Object.create(Cat); // this is a prototype object too | |
Garfield.color = 'orange'; | |
Garfield.color = 'fat'; | |
var garfield = Object.create(Garfield); | |
garfield.meow(); | |
catPrototype.purr = function () { | |
console.log("purrrr"); | |
}; | |
garfield.purr(); // ReferenceError: catPrototype is not defined | |
// as you where expecting ;) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment