-
-
Save lisaSwanson/ba467a1ebc0d57850fb3 to your computer and use it in GitHub Desktop.
Prototypical Dinosaurs
This file contains 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 Dinosaur(color){ | |
this.id = Dinosaur.prototype.counter++; | |
this.dob = Date.now(); | |
this.color = color; | |
}; | |
Dinosaur.prototype.roar = function(){ | |
console.log('RARWARARRR said the ' + this.color + ' Dinosaur!!!'); | |
}; | |
Dinosaur.prototype.counter = 1000; | |
var o = new Dinosaur('blue'); | |
var reddy = new Dinosaur('red'); | |
console.log(o); | |
console.log(reddy); | |
o.roar(); | |
reddy.roar(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment