> From: [EMAIL PROTECTED]
> Subject: Why is the code in iui.js all wrapped up in an 
> anonymous function?
> 
> What is the advantage of this way of constructing the .js 
> file?  Why not just load it straight?

The anonymous function creates a local scope so that local variables and 
functions do not conflict with any other variables or
functions in the page with the same names.

See the list of "var" variables at the beginning of the anonymous function? If 
they weren't inside the function, they would be
global variables.

It's a very common technique in JavaScript libraries to avoid name conflicts.

-Mike


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"iPhoneWebDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/iphonewebdev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to