Skip to content

Instantly share code, notes, and snippets.

@coolaj86
Created April 13, 2010 00:32
Show Gist options
  • Save coolaj86/364173 to your computer and use it in GitHub Desktop.
Save coolaj86/364173 to your computer and use it in GitHub Desktop.
// Crockford's Functional Inheritance Example
// Slide 68, Act III: Function the Ultimate
// http://yuiblog.com/crockford
// Parent
function gizmo(id) {
return {
id: id,
toString: function () {
return "gizmo " + this.id;
}
};
}
// Child
function hoozit(id) {
var that= gizmo(id);
that.test = function (testid) {
return testid === this.id;
};
return that;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment