Wednesday, May 20, 2015

JavaScript D3 - forEach() vs each() function

The main takeaway is that, using .each() you get access to 3 things you need: dthis and i. With .forEach(), on an array (like in the example from the beginning) you only get 2 things (d and i), and you'd have to do a bunch of work to also associate an HTML element with those 2 things. And that, among other things, is how d3 is useful.

http://stackoverflow.com/questions/13465796/d3-javascript-difference-between-foreach-and-each

No comments: