Javascript question: about variable definition
<p>I have no idea why it didn't work if I specify a variable with 'var':
like this:</p>

<pre><code>var mytool = function(){
      return {
         method: function(){}
     }
}();
</code></pre>

<p>And later I use it in the same template: mytool.method. This will output mytool was not defined.</p>

<p>But if I define it like this:</p>

<pre><code>     mytool = function(){
          return {
             method: function(){}
         }
    }();
</code></pre>

<p>Then it works.</p>
