Skip to content

Instantly share code, notes, and snippets.

@glesica
Created January 8, 2012 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glesica/1579166 to your computer and use it in GitHub Desktop.
Save glesica/1579166 to your computer and use it in GitHub Desktop.
javascript inheritance question
// base class
function Animal() {
// constructor
}
Animal.prototype.makeNoise = function() {
// make noise
}
// first sub-class
function Dog() {
// constructor
}
Dog.prototype = Animal.prototype;
Dog.prototype.makeNoise = function() {
bark();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment