Skip to content

Instantly share code, notes, and snippets.

@kparms
Created June 3, 2016 13:02
Show Gist options
  • Save kparms/f75469c8c02b21120b284ac638f44e7a to your computer and use it in GitHub Desktop.
Save kparms/f75469c8c02b21120b284ac638f44e7a to your computer and use it in GitHub Desktop.
Deduplicate Associated Array in JS
var parsedData = [];
/*KP: In parsedData we have a key called PsId */
/* KP: Deduplicate */
parsedData.forEach(function(value, key) {
var seen = [];
for (i=0; i < value.length; i++){
if (seen[value[i].PsId]) {
value.splice(i,1);
i--; }
else { seen[value[i].PsId]=true; }
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment