title: Best way to use selection.filter to get multiple selections
body: <p>I am just playing around with d3.js and I would like to know what's the best way to use <code>selection.filter()</code> or some other way to get multiple selections in a single loop.</p>
  
  <p>Thinking from an array perspective, I would use <code>Array.prototype.filter()</code> to get the required set of data. Whenever I need multiple set of data based on different condition I would use <code>Array.prototype.reduce()</code> and push the data to respective key in the accumulator as object. </p>
  
  <p>So with D3 selection how would I filter and and get the selection for different condition in a single loop.(something like <code>d3.reduce()</code>). So that I can use the selection methods over the filtered selections. I read the docs and I am aware that from v4 the selections are no more arrays.</p>