Todd , From my understanding its partly for variable scoping, partly for garbage collection and part of a pattern to emulate classes. I did a posting of the full pattern here: http://www.willjessup.com/?p=35
Will > Hello, > I've been poking around a bit in the jQuery source code. It's been > enlightening and has proven that I don't know as much about Javascript > as I thought I did! > > Here's a pattern that occurs frequently that I'm really curious about: > > new function() { > // do stuff > } > > Is the purpose of this just to provide local scope to the variables > used? Is there an equivalant syntax that may be more common? I > intuitively wouldn't even think the code inside the function would get > executed unless the whole thing was proceeded by "()", but obviously > I'd be wrong. What's really surprising is that I couldn't find any > information about this technique in a google search. > > Just curious. > > Thanks, > Todd > ------------------------------------------------------------------------ > > _______________________________________________ > jQuery mailing list > discuss@jquery.com > http://jquery.com/discuss/ > _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/