Created
November 15, 2011 14:10
-
-
Save Raynos/1367167 to your computer and use it in GitHub Desktop.
Super, not so hard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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