title: How to add non duplicate objects in an array in javascript?
body: <p>I want to add non-duplicate objects into a new array.</p>
  
  <pre><code>var array = [
    {
      id: 1,
      label: 'one'
    },
    {
      id: 1,
      label: 'one'
    },
    {
      id: 2,
      label: 'two'
    }
  ];
  
  var uniqueProducts = array.filter(function(elem, i, array) {
      return array.indexOf(elem) === i;
  });
  
  console.log('uniqueProducts', uniqueProducts);
  // output: [object, object, object] 
  </code></pre>
  
  <p><a href="https://jsfiddle.net/ptongalex/a17z2tyb/1/" rel="nofollow">live code</a></p>