Skip to content

Instantly share code, notes, and snippets.

@pr00thmatic
Created January 4, 2015 01:45
Show Gist options
  • Save pr00thmatic/6673196e840102c7874a to your computer and use it in GitHub Desktop.
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
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