title: Javascript SetTimeout and Loops
body: <p>Experts.
  Javascript not producing desired delay effect.<br>
  From other questions, on SO I got to know that, problem is with settimeout and the way I am using it.
  But still I am not able to comprehend, how Settimeout works. 
  So I am putting code here. 
  Need to use Javascript only, because of knowledge purpose.<br>
  Actually I am trying to clear my concepts about <strong>this, closure</strong> in javascript. 
  Are they kind of twisted things of Javascript?</p>
  
  <pre><code>var objImg = new Object();
  var h;
  var w;
  
  var no = 100;
  while (no != 500) {
      setTimeout(function () {
          size(no, no);
      }, 2000);
  
      /* it's get executed once, instead of repeating with while loop
      Does it leave loop in mid? I get image with 500px height and
      width, but effect is not acheived.
      */
  
      no = no + 50;
  }
  
  function size(h, w) {
      var objImg = document.getElementsByName('ford').item(0);
      objImg.style.height = h + 'px';
      objImg.style.width = w + 'px';
  }
  </code></pre>