Search code examples
javascriptoopinterfacesuperclass

Can you create an superclass of 2 javascript objects


I have a base object class called coretype e.g.

 function coreotype(a,b,c){
    var coreA= a;
    var coreB= b;
    var coreC= c;
    function coreF(){...do something...}
    }

I then have a number of modification processes e.g.

function modifyA(m1){var md1 = m1; function mf(){...do something...}}

and

function modifyA(m1){var md1 = m1; function mf(){...do something...}}

I want to create super object classes of the core type and the 1 of the modification processes to create new object classes e.g. typeA which is an object class of coref + modifyA

so that I can define an object by doing something like:

var thing1 = new typeA(a,b,c,m1)

Is this possible? Also can these super classes be made using an interface so that I could remove say coreB from the resulting super class or am I just expecting more OOP than javascript can deliver? I would prefer an answer using javascript over jquery as I would really like to understand how it is being done. Thanks


Solution

  • Since you really want to understand how this is done.. you must visit -

    http://prototypejs.org/learn/class-inheritance

    You are free to peek into prototypejs code.