Created
October 29, 2014 00:55
-
-
Save JacobHsu/3f3a4a040f875523846d to your computer and use it in GitHub Desktop.
#JS Penguins, Properties, and the Prototype
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
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