I have an array of objects that looks like the image below. Is there a way by which I can have an array that contains unique objects with respect to id ? We can
You could create a hash using the id as the key and keeping the value as the entire object:
var myHash = new Object();
var i;
for(i = 0; i < yourArray.length; i++) {
var yourObjId = yourArray[i][id];
myHash[yourObjId] = yourArray[i];
}
You would be left with a hash myHash
containing objects with unique id's (and only the last object of duplicates would be stored)