title: setInterval overriding others setIntervals
body: <p>I'm trying to create multiples setIntervals and store them (and clear later), but when I do this, the last setInterval override the previous, executing one time for each previous setInterval , but with the same content.</p>
  
  <p>Code snippet with the weird behaviour :</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var timeoutFunctions= {};
  
  function log_on_console(text){
    console.log(' &gt; &gt; &gt; inside function : '+text)
  }
  
  $( document ).ready(function() {
      for (i = 0; i &lt; 5; i++) {
        console.log(' &gt; &gt; &gt; before function : '+i)
        timeoutFunctions[i] = setInterval(function(){log_on_console(i)}, 2000);
      }
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>the output on console is :</p>
  
  <pre><code>" &gt; &gt; &gt; before function : 0" js:21:6
  " &gt; &gt; &gt; before function : 1" js:21:6
  " &gt; &gt; &gt; before function : 2" js:21:6
  " &gt; &gt; &gt; before function : 3" js:21:6
  " &gt; &gt; &gt; before function : 4" js:21:6
  
  " &gt; &gt; &gt; inside function : 5" (5) js:16:2 //(this one is the "problem")
  </code></pre>
  
  <p>I was expexcting something like this instead :</p>
  
  <pre><code>" &gt; &gt; &gt; before function : 0" js:21:6
  " &gt; &gt; &gt; before function : 1" js:21:6
  " &gt; &gt; &gt; before function : 2" js:21:6
  " &gt; &gt; &gt; before function : 3" js:21:6
  " &gt; &gt; &gt; before function : 4" js:21:6
  
  " &gt; &gt; &gt; inside function : 0" js:16:2 
  " &gt; &gt; &gt; inside function : 1" js:16:2 
  " &gt; &gt; &gt; inside function : 2" js:16:2 
  " &gt; &gt; &gt; inside function : 3" js:16:2 
  " &gt; &gt; &gt; inside function : 4" js:16:2 
  </code></pre>
  
  <p>so, why is the last <code>setInterval(function(){log_on_console(i)}, 2000)</code> overriding the previous four?</p>