title: understanding setTimeout example in ExtJs progressbar
body: <p>1.- Why is it necessary to return a function from updateFn? 
  If I run this code commenting the return function the progress bar would go directly to 100 %.</p>
  
  <p>2.- What are the differences when returning a function compared to just having the logic inside updateFn that makes returning a function necessary?</p>
  
  <pre><code> Ext.onReady(function(){
      Ext.MessageBox.show({   
          title       : 'Wait',
      msg         : 'Hold',
      progressText: "on going ...",
      width       : 300,
      progress    : true,
      closable    : false   
  });
  
  var updateFn = function(num){
      console.log('inside updateFn');
      return function(){ //if I comment this line the function gets immediately called (when executed from the for loop)
          console.log(num);
          if(num == 6){
              Ext.MessageBox.updateProgress(100, 'All items saved puto');
              Ext.Function.defer(Ext.MessageBox.hide, 1500, Ext.MessageBox);
          }
          else{
              var i = num / 6;
              var pct = Math.round(100 * i);
              Ext.MessageBox.updateProgress(i, pct + '% completed');
          }
  
  
      }
  };
  
  for(var i = 1; i &lt; 7; i++){
      console.log('inside for');
      setTimeout(updateFn(i),i * 2000); 
  }
  
  
  
  
  });
  </code></pre>