Skip to content

Instantly share code, notes, and snippets.

@JacobHsu
Created October 29, 2014 00:55
Show Gist options
  • Save JacobHsu/3f3a4a040f875523846d to your computer and use it in GitHub Desktop.
Save JacobHsu/3f3a4a040f875523846d to your computer and use it in GitHub Desktop.
#JS Penguins, Properties, and the Prototype
function Penguin(name) {
this.name = name;
this.numLegs = 2;
}
// create your Emperor class here and make it inherit from Penguin
function Emperor (name){
this.name = name;
}
// create an "emperor" object and print the number of legs it has
Emperor.prototype = new Penguin();
var emperor = new Emperor("Buddy");
console.log(emperor.numLegs);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment