Removing duplicates in array of objects
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/2218999/remove-duplicates-from-an-array-of-objects-in-javascript">Remove duplicates from an array of objects in javascript</a>  </p>
</blockquote>



<pre><code>var arr = [{empID:100,empName:greg},{empID:101,empName:Math},{empID:100,empName:greg}];
var sorted_arr = arr.sort(); // You can define the comparing function here. 
                             // JS by default uses a crappy string compare.
var results = [];
for (var i = 0; i &lt; arr.length - 1; i++) {
    if (sorted_arr[i + 1].empID != sorted_arr[i].empID) {
        results.push(sorted_arr[i]);
    }
}

alert(results);
</code></pre>

<p>I have an array of objects, but when i try to remove the duplicate object which matches the ID, it does not get removed. What's the issue with the code.</p>
