If you look at the last line of the function, it returns arguments.callee.
This is a pointer to the anonymous function. So the first call (with Array),
calls the anonymous function. It then returns itself and so the second call
does the same.

On Fri, Oct 3, 2008 at 8:01 AM, Nathan White <
[EMAIL PROTECTED]<[EMAIL PROTECTED]>
> wrote:

> I feel comfortable with the internals of mootools for the most part and
> love reading the code. However in 1.2.0 there is a bit of code that
> perplexes me.  I donno if I'm missing something or what. I figured I would
> ask for some help or clarification. I will note that in the nightly builds
> this code has been completely replaced with something that seems a bit more
> robust.
>
> In the Core.js file line 103-108
>
> (function(object, methods){
>     for (var i = methods.length; i--; i) Native.genericize(object,
> methods[i], true);
>     return arguments.callee;
> })
> (Array, ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift',
> 'concat', 'join', 'slice', 'toString', 'valueOf', 'indexOf', 'lastIndexOf'])
> (String, ['charAt', 'charCodeAt', 'concat', 'indexOf', 'lastIndexOf',
> 'match', 'replace', 'search', 'slice', 'split', 'substr', 'substring',
> 'toLowerCase', 'toUpperCase', 'valueOf']);
>
>
> I understand and recognize the anonymous function syntax (function(){})()
> but what I don't get is how the it appears the params are passed twice to
> the same anonymous function. The (Array...) followed by the (String...);
> doesn't makes sense to me. If I take this snippet of code out by itself
> modifying the internal function for generic debugging info it breaks. It
> handles the Array () fine but it gets to the String () and breaks.
>
> I looked above in the code to see if I was missing some other closure but I
> didn't see anything.
>
> Can anyone shed any light on this, and why it works?
>
>
>
> ------------------------------
>  View message @
> http://n2.nabble.com/confused-with-core.js-tp1142162p1142162.html
> To start a new topic under MooTools Users, email
> [EMAIL PROTECTED]<[EMAIL PROTECTED]>
> To unsubscribe from MooTools Users, click here< (link removed) >.
>
>
>


-----
The MooTools Tutorial:  http://www.mootorial.com www.mootorial.com 
CNET Clientside:  http://clientside.cnet.com clientside.cnet.com 
-- 
View this message in context: 
http://n2.nabble.com/confused-with-core.js-tp1142162p1142175.html
Sent from the MooTools Users mailing list archive at Nabble.com.

Reply via email to