Hi Lin,
this.initialize(arguments) would call the initialize method and pass
in an array of arguments as the first and only parameter to the
function. (Well, on many browsers 'arguments' isn't quite a real
array, but very similar to one.) this.initialize.apply(this,
arguments) calls the initialize method passing it the set of arguments
in the 'arguments' array as *individual* arguments.
So:
* * * *
var a = [1, 2, 3];
this.function(a);
// => Passes the function a single argument that's an array, [1,2,3]
this.function.apply(this, a);
// => Passes the function three individual arguments 1, 2, and 3
* * * *
You have to use the second 'this' because the JavaScript apply
function requires the context (the value to use for "this" during the
call) as the first argument, and then the arguments array as the
second argument. (It needs this for a good reason -- it doesn't have
access to the value otherwise, because of the way "this" works in
JavaScript.)
HTH,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available