Skip to content

Instantly share code, notes, and snippets.

@Sensiblemnd
Last active March 20, 2025 13:15
Show Gist options
  • Save Sensiblemnd/523f3c1c0710abbf18b1258b25bf6b81 to your computer and use it in GitHub Desktop.
Save Sensiblemnd/523f3c1c0710abbf18b1258b25bf6b81 to your computer and use it in GitHub Desktop.
remover dupes from json object
var data = {
"name.test": "Peter",
"name.test1": "Steve",
"name.test2": "Steve",
}
var unique = {};
var duplicates = {};
Object.keys(data).forEach(function (key) {
if (data[key] in unique) {
duplicates[key] = data[key];
delete data[key];
} else {
unique[data[key]] = data[key];
}
});
console.log(duplicates);
console.log(data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment