Home > Article > Web Front-end > Examples to explain JS implementation of removing duplicate json from arrays
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 it, hoping to help everyone better master it. Knowledge of js and json.
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; }
Have you all learned it? Hurry up and give it a try.
Related recommendations:
How Vue exports json data to Excel spreadsheet method
How jquery reads data from json and appends it to In html
Manipulate JSON objects in Javascript and add a simple implementation of deletion and modification
The above is the detailed content of Examples to explain JS implementation of removing duplicate json from arrays. For more information, please follow other related articles on the PHP Chinese website!