title: Javascript weird way of declaring and calling a function
body: <p>Hi I am new to javascript and I am trying to maintain someones code, but I cant seem to figure out what they are doing.</p>
  
  <p>They seem to be declaring a function like so:</p>
  
  <pre><code>(function(Module) {
      Module.register(...) {
         ....
         return ...;
      };
      Module.register(...) {
         ....
         return ...;
      };
   }(hb.Core));
  </code></pre>
  
  <p>If you wanted to create a function that called Module.register twice (which is what I think they are trying to do), wouldn't you do the following?</p>
  
  <pre><code>function myFunction(Module) {
       Module.register(...) {
          ...
       };
       Module.register(...) {
          ...
       };
  }
  myfunction(Module);
  </code></pre>
  
  <p>Also, don't know if this is really relevant, but they are using the sandbox model (where they have different modules communicate with the application core only through a sandbox).</p>
  
  <p>Hope someone can help out. I am really new to Javascript and front-end development in general and I am very confused.</p>