Skip to content

Instantly share code, notes, and snippets.

@MartinSvarrer
Created February 19, 2014 14:01
Show Gist options
  • Save MartinSvarrer/9092662 to your computer and use it in GitHub Desktop.
Save MartinSvarrer/9092662 to your computer and use it in GitHub Desktop.
ES5 way of doing inheritance
function SuperClass () {};
SuperClass.prototype = {
constructor: SuperClass,
a: 'Hello',
b: 'super',
c: function () {
return this.a + ', ' + this.b + '!';
}
};
function Sub () {};
Sub.prototype = Object.create(SuperClass.prototype, {
constructor: { value: Sub },
b: { value:'sub' }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment