title: how to exclude some elements from javascript Array.map() callback
body: <p>Essentially, I want to implement the following:</p>
  
  <pre><code>var categories = [];
  var products = // some array of product objects
  products.map(function(value) {
     if(categories.indexOf(value.Category === -1)) categories.push(value.Category);
  });
  </code></pre>
  
  <p>As result, <code>categories</code> array contains unique list of product categories.</p>
  
  <p>I <em>feel</em> that there should be a better way to do it, but nothing comes to mind. </p>
  
  <p>If there <em>isn't</em> then probably there is no point to use <code>map()</code> in the first place. I could do as simple as</p>
  
  <pre><code>var categories = [];
  var products = // some array of product objects
  for (var i = 0; i &lt; products.length; i++) {
     if(categories.indexOf(products[i].Category === -1)) categories.push(products[i].Category);
  }
  </code></pre>
  
  <p>UPDATE for those who insist it's a duplicate of "how to make an array unique" question. I saw that post, and for my situation I don't think it applies. I <strong>don't</strong> have an array of values that I need to make unique. I have an array of objects and I need to <strong>build</strong> an array of unique values. The difference might be subtle - but to get to the use case of that topic I would build a non-unique array and then make it unique. Seems even worse than my original solution</p>