Home >Web Front-end >JS Tutorial >How to remove duplicate json using JS
This article mainly introduces the JS method to remove duplicate json in the array, involving JavaScript traversal, judgment, access and other related operation skills for json array data. Friends in need can refer to this article
The example describes how to implement JS to remove duplicate json in an array. Share it with everyone for your reference, the details are as follows:
var array = [{"name":"123"},{"name":"123"},{"name":"456"}]; unique(array); function unique(list) { var arr = []; for (var i = 0; i < list.length; i++) { if (i == 0) arr.push(list[i]); b = false; if (arr.length > 0 && i > 0) { for (var j = 0; j < arr.length; j++) { if (arr[j].typesname == list[i].typesname) { b = true; //break; } } if (!b) { arr.push(list[i]); } } } return arr; }
The above is what I compiled for everyone, I hope it will be helpful to everyone in the future.
Related articles:
How to implement sensitive text prompts in Angular
How to implement hidden display in Angular
How to realize left and right sliding of pictures in js
How does BrowserRouter cooperate with react-router server
How in javaScript Connect the printer
How to pass events in the vue component
Introduce in detail the use of Vue event modifier capture
404 problem occurs when refreshing the page in react-router
How to change the avatar in node
How to use it in JavaScript Generator method
How to implement object management of url in js
The above is the detailed content of How to remove duplicate json using JS. For more information, please follow other related articles on the PHP Chinese website!