JSuper provides an efficient way of defining a class-like super variable on any JavaScript function or object.
Defines a global $super function which when used inside a defined function, calls the constructor of the inherited prototype. All properties of the inherited prototype can be used as normal.
Because $super is defined globally, consider the following:
// Correctvar jsuper = ; // Incorrect, global $super function has been overridden.var $super = ;
If a function's first argument is $super, then the inherited proxy is hooked to that variable instead. Note that the argument is invisible outside the function. This is identical behaviour to PrototypeJS. The above caution does not apply in this case.
Documentation coming soon!
Performance
Case: No super calls
Operations/second: N
{} for var i = 0; i < M; i++ ;// N = time / M
Case: Single super call
Operations/second: 0.7 * N
// Tell JSHint to expect a global variable/* global $super */ var jsuper = ; util = ; var F1 = ;util; for var i = 0; i < M; i++ ;// N = time / M
Case: Nested super call
Operations/second: 0.3 * N
var F2 = ;util; for var i = 0; i < M; i++ ;// N = time / M