Skip to content

Instantly share code, notes, and snippets.

@DForshner
Last active December 17, 2015 00:59
Show Gist options
  • Save DForshner/5525304 to your computer and use it in GitHub Desktop.
Save DForshner/5525304 to your computer and use it in GitHub Desktop.
JavaScript Prototype Pattern
// The Prototype pattern allows objects to be created
// based on a template of an existing object using cloning.
var Dragon = {
name: "TROGDOR"
};
//Object.create takes its first argument and applies it to the prototype of your new object.
var myDragon = Object.create(Dragon);
console.log(myDragon.name);
myDragon.name = "TROGDOR the burninator!";
console.log(myDragon.name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment