title: How to make Backbone.js Collection items Unique?
body: <p>Say I have these Backbone.js Model:</p>
  
  <pre><code>var Truck = Backbone.Model.extend({});
  
  var truck1 = new Truck();
  var truck2 = new Truck();
  
  truck1.set("brand", "Ford");
  truck2.set("brand", "Toyota");
  truck3.set("brand", "Honda");
  truck4.set("brand", "Ford");
  </code></pre>
  
  <p>Then, let's say we have a Backbone.js Collection:</p>
  
  <pre><code>var TruckList = Backbone.Collection.extend({
    model: Truck,
    comparator: function(truck) {
       return truck.get("brand");
    };
  
  });
  </code></pre>
  
  <p>I'm a car collector, so time to add each car to my collection:</p>
  
  <pre><code>Trucks = new TruckList();
  Trucks.add(truck1);
  Trucks.add(truck2);
  Trucks.add(truck3);
  Trucks.add(truck4);
  </code></pre>
  
  <p>Just focusing on the brand attribute, truck4 is a duplicate of truck1. I can't have duplicates in my Collection. I need my collection to have unique values. </p>
  
  <p>My question is, How do I remove duplicate items from my Backbone.js Collection?</p>
  
  <p>Should I use Underscore.js for this? If so, can someone please provide a working/runnable example of how to do this.</p>
  
  <p>Assume the following:</p>
  
  <p>1.Collection is not sorted</p>
  
  <ol>
  <li><p>Removal must be done on brand attribute value</p></li>
  <li><p>Ajax call to populate each instance of a Truck. This means when adding to a collection, you don't have access to the Truck properties.</p></li>
  </ol>