Skip to content
darrinr edited this page May 19, 2013 · 2 revisions

SUPER is a special function used to retrieve a superclass’ version of a given method bound to the provided object. SUPER is provided as the second argument to the iz.Package’s class creation function, as such it can be used within any method created within the class. It is usually called as follows:

Example

 iz.Package('Bird.Duck', { extends: 'Bird'}, function(Class, SUPER) {

        Class.take_off = function() {
            SUPER(this, 'take_off')();
            // do other Duck related take-off things
        };
    });

A note about SUPER: Access to an object’s superclass methods can be difficult to accomplish reliably in javascript. IZ’s SUPER sidesteps these issues and creates a reliable mechanism for accessing the methods an object inherits, provided it is called as a function as described above. SUPER can, in fact, be called as a method, obj.SUPER(methodname), however doing this within a method will behave unreliably. It is provided only for the rare situation where you need to access the superclass from outside a named method or in a situation where the method is created after object creation. It is recommended that you avoid the obj.SUPER() calling semantics unless you know exactly what you are doing.

Clone this wiki locally