title: Most efficient way of changing speed mid interval?
body: <p>I want to change the speed of steinterval() while running I tried something like this:</p>
  
  <pre><code>inteval = 1;
  setInterval(function(){
      }, interval);
  interval = 2;
  </code></pre>
  
  <p>Then I tried this which doesn't use intervals, but seems to work fine:</p>
  
  <pre><code>// Time
  inteval = 1;
  function refresh() {
      setTimeout(function() {refresh()},interval);
      }
  refresh();
  interval = 2;
  </code></pre>
  
  <p>I would rather have used setinterval() but this approach works fine. However in another similar question there is a longer approach: <a href="https://stackoverflow.com/questions/1280263/changing-the-interval-of-setinterval-while-its-running">Changing the interval of SetInterval while it&#39;s running</a></p>
  
  <p>If my snippet good in terms of efficiency? Is there a more efficient approach?</p>