title: What does `new` in JavaScript do, anyway?
body: <p>I am very confused about how constructors work in Javascrpt; despite using the language for several years (mostly as if it were like a semi-imperative version of LISP) I would like to know more about how objects are supposed to work in it.</p>
  
  <p>Given this code:</p>
  
  <pre><code>function Foo(x) {
      return {
          bar: function() { return x; }
      };
  }
  </code></pre>
  
  <p>What is the difference between calling <code>myFoo = Foo(5)</code> and <code>myFoo = new Foo(5)</code>?  Or, in other words, what exactly does a constructor in Javascript <em>do</em>?</p>