title: Why is it that variable re-declaration is not an error in JavaScript?
body: <pre><code>function foo(){
      var bar = 3
      return bar;
      var bar = 8
  }
  alert(foo());  //prints 3
  </code></pre>
  
  <p>Doing something like this in C++ would throw an error. What was the motive behind making this design decision?</p>