Last active
March 20, 2025 13:15
-
-
Save Sensiblemnd/523f3c1c0710abbf18b1258b25bf6b81 to your computer and use it in GitHub Desktop.
remover dupes from json object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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