title: Stop loop when condition variable (global var) changes in javascript
body: <p>I'm having a problem that I can't solve. I have a loop in javascript where the condition variable to stop depends on a global variable. The loop starts looping and when I change the value of that global variable it never stops.</p>
  
  <pre><code>stop = false;
  var i = 0;
  while ((stop == false) &amp;&amp; (i&lt;100000)){
      console.log("hi-"+i);
      i++;
  }
  </code></pre>
  
  <p>While loop is running, if I do stop = true, it never stops. I do not know why is that.</p>
  
  <p>Any idea?</p>
  
  <p>Thanks!</p>