Created
June 30, 2012 16:10
-
-
Save Lin4ipsum/3024410 to your computer and use it in GitHub Desktop.
Rabbit Constructor in JS
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
// first we can make the instructor | |
function Rabbit(adjective) { | |
this.adjective = adjective; | |
this.describeMyself = function() { | |
console.log("I am a " + this.adjective + " rabbit"); | |
}; | |
} | |
// now we can easily make all of our rabbits | |
var rabbit1 = new Rabbit("fluffy"); | |
var rabbit2 = new Rabbit("happy"); | |
var rabbit3 = new Rabbit("sleepy"); | |
rabbit1.describeMyself(); | |
rabbit2.describeMyself(); | |
rabbit3.describeMyself(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment