admin管理员组文章数量:1297016
I have a multi dimentional array as following. I need to delete the previous row if the value of the particular key value duplicates
[
{"id":5, "name":"abc"}
{"id":5, "name":"abcd"}
{"id":6, "name":"abcde"}
]
I need to get the result as following after deleting the previous row if the value of id already exists.
[
{"id":5, "name":"abcd"}
{"id":6, "name":"abcde"}
]
I have a multi dimentional array as following. I need to delete the previous row if the value of the particular key value duplicates
[
{"id":5, "name":"abc"}
{"id":5, "name":"abcd"}
{"id":6, "name":"abcde"}
]
I need to get the result as following after deleting the previous row if the value of id already exists.
[
{"id":5, "name":"abcd"}
{"id":6, "name":"abcde"}
]
Share
Improve this question
asked Feb 22, 2018 at 8:05
HareeshHareesh
1,5874 gold badges21 silver badges48 bronze badges
4
- 2 Do you want to always remove the previous row or just the existing row that has similar id? – Giovanni Lobitos Commented Feb 22, 2018 at 8:07
- is there only one dupe? do you want only the last one if one or more dupes? what have you tried? – Nina Scholz Commented Feb 22, 2018 at 8:07
- its not clear from your question by what rules/criteria you want to remove a lookalike array (syntactically they're not duplicate). – izengod Commented Feb 22, 2018 at 8:12
- @GiovanniLobitos and NinaScholz It may have more than one array with same id and i always want to remove the previous row and keep the last row. – Hareesh Commented Feb 22, 2018 at 8:53
2 Answers
Reset to default 10Map
can be leveraged to produce a pretty cool one-liner
本文标签: ReactJSJavascript How to remove the duplicate array from multi dimentional arrayStack Overflow
版权声明:本文标题:ReactJSJavascript How to remove the duplicate array from multi dimentional array? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741644213a2390092.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论