title: Passing variables between two JavaScript modules not working
body: <p>I have two modules within the same <code>namespace</code>, and I want to pass a variable between them. The namespace is called <code>app</code>, and the variable is <code>a</code> - but for some reason my variable <code>a</code> always comes out <code>null</code> when my method is called.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>// module 1
  (function() {
      app.module1 = (function() {
          var a = null; 
          canvas.addEventListener('mousedown', function(e) {
              a = { message: hallo };
              app.module2.print();
          }, 0);
  
          return {
              a: a
          };
      })();
  })();
  
  // module 2
  
  (function() {
      app.module2 = (function() {
          var print = function() {
              console.log(app.module1.a);
          }
  
          return {
              print: print
          };
      })();
  })();
  </code></pre>