Loading ...
Sorry, an error occurred while loading the content.

44783Re: [ydn-javascript] Advantage of having anonymous function executing immediately

Expand Messages
  • Adam Moore
    Feb 5, 2009
    • 0 Attachment
      On Thu, Feb 05, 2009 at 10:50:40PM -0000, kashodiya wrote:
      > What is the real advantage of this style of programing?

      > ----------------------------
      >
      > (function() {
      > YAHOO.example.app = {
      > ...
      > };
      >
      > //Call loader the first time
      > var loader = new YAHOO.util.YUILoader({
      > ...
      > onSuccess: function() {
      > ...
      > }
      > });
      > loader.insert();
      > })();

      The loader variable is scoped to the anonymous function. It would be
      global if the function wrapper were omitted, which is something we
      like to avoid.

      -Adam
    • Show all 2 messages in this topic