title: difference between function(d) and function(d,i)?
body: <p>Every <strong>D3js beginner</strong> must be going through this thought, I am pretty much sure about it.</p>
  
  <p>I have been around this thing for few hours now!!!!But I don't know how to use it and what is the <strong>difference</strong> between them?</p>
  
  <pre><code>function(d){return d}
  
  function(d,i){return d and some more custom code}
  </code></pre>
  
  <p>for Example---></p>
  
  <p>var data = [4, 8, 15, 16, 23, 42];</p>
  
  <pre><code>    Function(d):::::
  
      chart.selectAll("div")
           .data(data)
           .enter().append("div")
           .style("width", function(d) { return d * 10 + "px"; })
           .text(function(d) { return d; });
  
      ------------------------------------------------------------------------------------
  
   Function(d*i):::::
  
      chart.selectAll("rect")
          .data(data)
          .enter().append("rect")
          .attr("y", function(d, i) { return i * 20; })
          .attr("width", x)
          .attr("height", 20);
  </code></pre>