title: How to trace in the console how many intervals are being executed - JavaScript
body: <p>I have a problem trying to know if a setInterval() is taking place or it was killed.
  I am creating an interval and saving it into a variable:</p>
  
  <pre><code>interval = setInterval('rotate()',3000);
  </code></pre>
  
  <p>Then on click to an element I stop the interval and wait 10 seconds before starting a new one, by the way the variable interval is global:</p>
  
  <pre><code>$(elm).click(function(){
  
    clearInterval(interval);
    position = index;
  
    $('#banner div').animate({
      'margin-left':position*(-img_width)
    });
  
    setTimeout('startItnerval()',10000);
  
  
  });
  
  function startItnerval(){
  
      interval = setInterval('rotate()',3000);
  
  }
  </code></pre>
  
  <p>It seems to work but eventually I can realize that there are intervals still being in place, everytime I start a new interval it is saved in the interval variable, which is global, so in theory even if I start 100 intervals they are all saved in the same variable replacing the previous interval right? So I should only have one instance of interval; then on  <code>clearInterval(interval);</code> it should stop any instance.</p>
  
  <p>After looking at the results, apparently even if it is saved in the same variable, they are all separate instances and need to be killed individually.</p>
  
  <p>How can I trace how many intervals are being executed, and if possible identify them one by one? even if I am able to solve the problem <strong>I really would like to know if there is a way to count or show in the console how many intervals are being executed?</strong></p>
  
  <p>thanks</p>