0
我有一個數組對象,其中的某個鍵的值可能會重複出現。還有另一個屬性的值+常量。我的目標是根據重複的位置添加一個數字。因此,例如,我的陣列看起來像這樣如何查找對象數組中的重複項並調整重複位置的值
[{
"id": "53990XXXX",
"components": {
"CategorySnippet": "snippet-53990XXXX"
}
}, {
"id": "56990XXXX",
"components": {
"CategorySnippet": "snippet-56990XXXX"
}
}, {
"id": "54980XXXX",
"components": {
"CategorySnippet": "snippet-54980XXXX"
}
}, {
"id": "53990XXXX",
"components": {
"CategorySnippet": "snippet-53990XXXX"
}
}]
我希望它是這樣
[{
"id": "53990XXXX",
"components": {
"CategorySnippet": "snippet-53990XXXX"
}
}, {
"id": "56990XXXX",
"components": {
"CategorySnippet": "snippet-56990XXXX"
}
}, {
"id": "54980XXXX",
"components": {
"CategorySnippet": "snippet-54980XXXX"
}
}, {
"id": "53990XXXX",
"components": {
"CategorySnippet": "snippet-53990XXXX_1"
}
}]
我應該怎麼做這個用純JS?
我無法找到這兩者之間的區別 – brk
@brk - CategorySnippet「:」snippet-53990XXXX_1「基本上不能在CategorySnippet對象中重複。 – soum