Function to remove duplicates object from array
function remove_duplicates(objectsArray) {
var usedObjects = {};
for (var i = objectsArray.length - 1; i >= 0; i--) {
var so = JSON.stringify(objectsArray[i]);
if (usedObjects[so]) {
objectsArray.splice(i, 1);
} else {
usedObjects[so] = true;
}
}
return objectsArray;
}
function remove_duplicates(objectsArray) {
var usedObjects = {};
for (var i = objectsArray.length - 1; i >= 0; i--) {
var so = JSON.stringify(objectsArray[i]);
if (usedObjects[so]) {
objectsArray.splice(i, 1);
} else {
usedObjects[so] = true;
}
}
return objectsArray;
}
No comments:
Post a Comment