about source code Class.create()

15 views
Skip to first unread message

BeiMingyu

unread,
Dec 4, 2011, 7:53:42 PM12/4/11
to prototype-s...@googlegroups.com
 I have a problem  about the source code (version 1.7):
var Class = (function() {
    function create() {
    var parent = null, properties = $A(arguments);
    if (Object.isFunction(properties[0]))
      parent = properties.shift();
    function klass() {
      this.initialize.apply(this, arguments);   // Where has the method   initialize  been defined??
    }
}
Where has the method   initialize  been defined??

T.J. Crowder

unread,
Dec 5, 2011, 3:15:59 AM12/5/11
to Prototype & script.aculo.us
On Dec 5, 12:53 am, BeiMingyu <cwen1...@gmail.com> wrote:
>  I have a problem  about the source code (version 1.7):
> var Class = (function() {
>     function create() {
>     var parent = null, properties = $A(arguments);
>     if (Object.isFunction(properties[0]))
>       parent = properties.shift();
>     function klass() {
>      * this.initialize.apply(this, arguments);   // Where has the method
> initialize  been defined??
> *    }}
>
> *Where has the method   initialize  been defined??*

It can be defined by the specification object passed into
Class.create. If it isn't, a default is defined about 15 lines further
down:

if (!klass.prototype.initialize)
klass.prototype.initialize = Prototype.emptyFunction;

HTH,
--
T.J. Crowder
Independent Software Engineer
tj / crowder software / com
www / crowder software / com

Reply all
Reply to author
Forward
0 new messages