title: Javascript scope issues with Revealing Module Pattern
body: <p>One more JavaScript scoping problem. I believe this is not related to 'hoisting'.</p>
  
  <p>I've a small block of code here - <a href="http://jsfiddle.net/0oqLzsec/2/" rel="nofollow">http://jsfiddle.net/0oqLzsec/2/</a></p>
  
  <pre><code>var c = function(){
      var x = 'before',
          callBefore = function(){
              alert(x);
          },
          callAfter = function(){
              _callAfter();
          };
  
      return{
          callBefore : callBefore,
          callAfter : callAfter
      }
  
      var y = 'after';
  
      function _callAfter(){
          alert(y);
      }
  };
  
  var obj = c();
  obj.callBefore();
  obj.callAfter();
  </code></pre>
  
  <p><code>callAfter()</code> always alerts 'undefined' even if the variable y is defined before <code>_callAfter()</code>. But If I move the variable y declaration before variable x it is working.</p>
  
  <p>I'm wondering if <code>callAfter()</code> can <code>_callAfter()</code> which is defined below, why can't it read variable y?</p>