Skip to content

Instantly share code, notes, and snippets.

@simonrenoult
Last active December 29, 2015 07:59
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 simonrenoult/7640089 to your computer and use it in GitHub Desktop.
Save simonrenoult/7640089 to your computer and use it in GitHub Desktop.
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