title: How to pass an index into setTimeout
body: <p>I know there are a lot of questions similar to this on here, but none that I've seen answer this for me.  If I missed one, and this is a duplicate, sorry.</p>
  
  <p>I'm trying to modify my graph using d3 and want to use setTimeout to space the operations in a nice looking way.</p>
  
  <p>I have </p>
  
  <pre><code>for (var key in alist){
      setTimeout(function () {
          graph.removeLink(alist[key].source.name, alist[key].target.name);
      }(key), key*500+200);
  }
  </code></pre>
  
  <p>This calls the removeLink function immediately instead of waiting the set interval.</p>
  
  <p>I'm new to javascript, so sorry if this is something exceptionally obvious, I can't find an answer anywhere.</p>