Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Classical inheritance. Use Object.create to inherit object. Javascript >= 1.8.5
var Parent = function ( settings ) {
this.name = settings.name;
};
Parent.prototype.greet = function () {
console.log ( 'Hello ' + this.name );
};
var Child = function ( settings ) {
Parent.call ( this, settings );
};
Child.prototype = Object.create ( Parent.prototype );
Child.prototype.constructor = Child;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment