0

creating a class

Hello,
I have been reading the documentation for the Component infrastructure like Attribute, Base, Plugin and Widget.
I keep coming across this concept of creating a base class and then extending, augmenting or plugin it, the code looks something like this:

CODE
 function MyClass(config) {

// Invoke Base constructor, passing through arguments
MyClass.superclass.constructor.apply(this, arguments);
}


Can someone please explain this function to me, how does it work?
I am familiar with constructor and apply but I cannot find an explanation of what is the superclass property or method.
What is superclass? Is it a YUI property or is it a JavaScript property?
What is the context of the argument this?
Is arguments an array and what value does it hold?

Thanks, I will appreciate it if someone will point me in the right direction

by
1 Reply
  • QUOTE (80D1 @ Jun 5 2011, 05:00 AM) <{POST_SNAPBACK}>
    Hello,
    I have been reading the documentation for the Component infrastructure like Attribute, Base, Plugin and Widget.
    I keep coming across this concept of creating a base class and then extending, augmenting or plugin it, the code looks something like this:

    CODE
     function MyClass(config) {

    // Invoke Base constructor, passing through arguments
    MyClass.superclass.constructor.apply(this, arguments);
    }


    Can someone please explain this function to me, how does it work?
    I am familiar with constructor and apply but I cannot find an explanation of what is the superclass property or method.
    What is superclass? Is it a YUI property or is it a JavaScript property?
    What is the context of the argument this?
    Is arguments an array and what value does it hold?

    Thanks, I will appreciate it if someone will point me in the right direction



    In regard to this post I made, I would like to say that I have been reading some books and came across the concept of a superclass in PHP and other programming languages and it seems to me like a superclass is supposed to refer to a parent class. This has led me to believe that even in JavaScript and YUI, that a superclass will most likely mean a parent class of some sort.
    0
This forum is locked.

Recent Posts

in YDN Documentation