title: Explain the following JavaScript statement?
body: <pre><code>var ninja = (function(){
      function Ninja(){};
      return new Ninja();
  })();
  </code></pre>
  
  <p>Why is the function above encapsulated in parentheses and why is there a <code>();</code> at the end?</p>
  
  <p>I think it's a constructor function because of the <code>();</code> at the end, but why is the object wrapped in parentheses?</p>