title: Output of code in Javascript
body: <p>As per hoisting concept, when this code snippet is run, all variable declarations are moved to top of code by compiler.So passed variable value 7 should be used instead of 2. Kindly explain the behavior.</p>
  
  <pre><code>var passed = 2;
  
  var addTo = function() {
  var inner = 3;
  return inner + passed;
  }
  
  var addTo = function() {
  var inner = 5;
  alert(inner + " " + passed);
  return inner + passed;
  }
  
  
  console.log(addTo());
  var passed = 7;
  
  O/P : 5 2
  Intended O/P 5 7
  </code></pre>