title: Two functions with the same name in JavaScript - how can this work?
body: <p>As far as I know, <code>function foo() { aaa(); }</code> is just <code>var foo = function(){ aaa() }</code> in JavaScript. So adding <code>function foo() { bbb(); }</code> should either overwrite the <code>foo</code> variable, or ignore the second definition - that's not the point. The point is that there should be one variable <code>foo</code>.</p>
  
  <p>So, in this example the <code>me</code> variable should <strong>not</strong> be correctly resolved from inside the methods <strong>and it is not in Explorer 8 :-)</strong>. I came to this example by trying to wrap them into another closure where (<code>var</code>) <code>me</code> would be, but I was surprised that it's not necessary:</p>
  
  <pre class="lang-javascript prettyprint-override"><code>    var foo = {
          bar1 : function me() {
              var index = 1;
              alert(me);
          },
          bar2 : function me() {
              var index = 2;
              alert(me);
          }    
      };
  
      foo.bar1(); // Shows the first one
      foo.bar2(); // Shows the second one
  </code></pre>
  
  <p>Demo: <a href="http://jsfiddle.net/W5dqy/5/" rel="noreferrer">http://jsfiddle.net/W5dqy/5/</a></p>