Skip to content

Instantly share code, notes, and snippets.

@ryanflorence
Created March 13, 2014 21:16
Show Gist options
  • Save ryanflorence/9537139 to your computer and use it in GitHub Desktop.
Save ryanflorence/9537139 to your computer and use it in GitHub Desktop.
var Foo,
__hasProp = {}.hasOwnProperty,
var __extends = function(child, parent) {
// direct property injection of parent constructor Function
for (var key in parent) {
if (__hasProp.call(parent, key))
child[key] = parent[key];
}
// new "wrapper" constructor function
function ctor() {
// make so ctor thinks its `instanceof child` event thought its a ctor
this.constructor = child;
}
// inherit the prototype methods to the wrapper
ctor.prototype = parent.prototype;
// set the prototype to a new instance of ctor
child.prototype = new ctor();
// allow calling super
child.__super__ = parent.prototype;
// return
return child;
};
Foo = (function(_super) {
__extends(Foo, _super);
function Foo() {
return Foo.__super__.constructor.apply(this, arguments);
}
return Foo;
})(Bar);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment