Skip to content

Instantly share code, notes, and snippets.

@Raynos
Created November 15, 2011 14:10
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 Raynos/1367167 to your computer and use it in GitHub Desktop.
Save Raynos/1367167 to your computer and use it in GitHub Desktop.
Super, not so hard
// super simply snips the current objects [[Prototype]] out of the chain.
// It then continues to operate on the object and places that [[Prototype]] back in the chain when
// we are done.
var Base = {
super: function(method) {
var _proto = this.__proto__;
var args = [].slice.call(arguments, 1);
this.__proto__ = _proto.__proto__;
try {
this[method].apply(this, args);
} finally {
this.__proto__ = _proto;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment