Skip to content

Instantly share code, notes, and snippets.

@sammoore
Created December 7, 2016 23:36
Show Gist options
  • Save sammoore/cbe7e65233dcb8681bf6b06d809ec2ce to your computer and use it in GitHub Desktop.
Save sammoore/cbe7e65233dcb8681bf6b06d809ec2ce to your computer and use it in GitHub Desktop.
inherits, as implemented in NodeJS circa ES5, but also defining superClass_ to maintain compatibility with existing in-browser inherits implementations.
'use strict';
function inherits(ctor, superCtor) {
ctor.superClass_ = ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true,
},
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment