Home  >  Article  >  Web Front-end  >  Summary of array element deduplication

Summary of array element deduplication

巴扎黑
巴扎黑Original
2016-12-10 09:12:36963browse

Summary of deduplication methods
① Traverse the empty array, indexOf method
var n = []; //A new temporary array
for(var i = 0; i < arr.length; i++){//Traverse the empty array
                                                                                                                                                                                                    ② You can also create empty objects
var n = {};
for(var i=0;i< arr.length;i++)

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn