title: Pass current element index to a function in D3
body: <p>I use code from <a href="https://www.dashingd3js.com/svg-paths-and-d3js" rel="nofollow">this example</a> to create a set of independent lines as <code>path</code> elements:</p>
  
  <pre><code>svgContainer.append("path")
              .attr("d", lineFunction(lineData))
              .attr("stroke", "blue")
              .attr("stroke-width", 2)
              .attr("fill", "none");
  </code></pre>
  
  <p>As I have all lines data in lineData array, in each iteration I want to pass only a single item from it, like <code>lineFunction(lineData[i])</code>. My question is how can I get this current index as I can usually do with <code>someFunction(d, i){}</code> in D3?</p>