title: Accessing variables outside method call on an object without making them global (is it possible?)
body: <p>I found out I have two functions the share some some code so I decided to put it insied a <em>template</em> function:</p>
  <pre><code>function template(callback){
    var all, these, variables, are, used, inthe, callbackFunction;
    for (var i=0; i&lt;10; i++){
        callback();
    }
  }
  function myFirstFunction(){
     //do something with all those variables
  }
  function mySecondFunction(){
     //do something else
  }
  </code></pre>
  <p>So for each function I call <code>template(myFirstFunction)</code> and <code>template(mySecondFunction)</code></p>
  <p>Is there any way I can use all variables defined in <em>template</em> function from my functions without passing them by parameter?</p>
  <hr />
  <h3>EDIT:</h3>
  <p>My functions are actually methods of an object:</p>
  <pre><code>function MyObject(){
  
  };
  MyObject.prototype.template = function(){ 
    var all, these, variables, are, used, inthe, callbackFunction;
    for (var i=0; i&lt;10; i++){
      callback();
    }};
  MyObject.prototype.myFirstMethod = function(){ 
      this.template(function(){
          //doSomething with all those variables
      });
  };
   MyObject.prototype.mySecondMethod = function(){ 
      this.template(function(){
          //doSomething else
      });
  };
  </code></pre>