Skip to content

Instantly share code, notes, and snippets.

@stujo
Created August 24, 2015 22:22
Show Gist options
  • Save stujo/24ec5af815ed851e8b52 to your computer and use it in GitHub Desktop.
Save stujo/24ec5af815ed851e8b52 to your computer and use it in GitHub Desktop.
Prototypical Dinosaurs
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