Skip to content

Instantly share code, notes, and snippets.

@coolaj86
Created April 13, 2010 00:37
Show Gist options
  • Select an option

  • Save coolaj86/364174 to your computer and use it in GitHub Desktop.

Select an option

Save coolaj86/364174 to your computer and use it in GitHub Desktop.
// Crockford's Prototypal Inheritance Example
// Slide 53, Act III: Function the Ultimate
// http://yuiblog.com/crockford
// Parent
var gizmo = new_constructor(Object, function (id) {
this.id = id;
}, {
toString: function () {
return "gizmo " + this.id;
}
});
// Child
var hoozit= new_constructor(gizmo, function (id) {
this.id = id;
}, {
test: function (id) {
return this.id === id;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment