Skip to content

Instantly share code, notes, and snippets.

@jdaly13
Created June 3, 2013 20:16
Show Gist options
  • Save jdaly13/5701015 to your computer and use it in GitHub Desktop.
Save jdaly13/5701015 to your computer and use it in GitHub Desktop.
Inheritance Pattern Classical
function inherit(C, P) {
var F = function () {};
F.prototype = P.prototype;
C.prototype = new F();
C.uber = P.prototype;
C.prototype.constructor = C;
}
function Parent () {}
Parent.prototype.getName = function () {
return this.name
}
function Child(name, dob, maleOrFemale) {
this.name = name;
this.birthdate = dob;
this.sex = maleOrFemale;
}
inherit(Child, Parent);
var child = new Child("joe", "5/29/89", "male");
child.getName() //outputs Joe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment