title: Does this way of defining JS objects have any purpose?
body: <p>I'm maintaining some legacy code and I've noticed that the following pattern for defining objects is used:</p>
  
  <pre><code>var MyObject = {};
  
  (function (root) {
  
      root.myFunction = function (foo) {
          //do something
      };
  
  })(MyObject);
  </code></pre>
  
  <p>Is there any purpose to this? Is it equivalent to just doing the following?</p>
  
  <pre><code>var MyObject = {
  
      myFunction : function (foo) {
          //do something
      };
  
  };
  </code></pre>
  
  <p>I'm not about to embark in a holy quest to refactor the whole codebase to my likings, but I'd really like to understand the reason behind that roundabout way of defining objects.</p>
  
  <p>Thanks!</p>