title: What is the significance of the Javascript constructor property?
body: <p>Trying to bend by head around Javascript's take on OO...and, like many others, running into confusion about the <code>constructor</code> property. In particular, the significance of the <code>constructor</code> property, as I can't seem to make it have any effect. E.g.:</p>
  
  <pre><code>function Foo(age) {
      this.age = age;
  }
  
  function Bar() {
      Foo.call(this, 42);
      this.name = "baz"; 
  }
  
  Bar.prototype = Object.create(Foo.prototype); 
  var b = new Bar;    
  
  alert(b.constructor); // "Foo". That's OK because we inherit `Foo`'s prototype.
  alert(b.name);        // "baz". Shows that Bar() was called as constructor.
  alert(b.age);         // "42", inherited from `Foo`.
  </code></pre>
  
  <p>In the above example, the object <code>b</code> seems to have had the right constructor called (<code>Bar</code>) &ndash; and it inherits the age property from <code>Foo</code>. So why do many people suggest this as a necessary step:</p>
  
  <pre><code>Bar.prototype.constructor = Bar;
  </code></pre>
  
  <p>Clearly, the right <code>Bar</code> constructor <em>was</em> called when constructing <code>b</code>, so what impact does this prototype property have? I am curious to know what practical difference it actually makes to have the constructor property set 'correctly'—as I can't see it having any affect on which constructor is actually called after an object is created.</p>