In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to remove the repetition and reorder the es6 array". In the daily operation, I believe many people have doubts about how to remove the repetition and reorder the es6 array. The editor consulted all kinds of data and sorted out a simple and useful method of operation. I hope it will be helpful to answer the question of "how to remove the repetition and reorder the es6 array". Next, please follow the editor to study!
Remove repetition and sort the method: 1, use "Array.from (new Set (arr))" or "[… new Set (arr)]" statement, remove the repeating elements in the array and return to the new array after deduplication; 2, use sort () to sort the deduplicated array, syntax "de-duplicated array .sort ()".
The operating environment of this tutorial: windows7 system, ECMAScript version 6, Dell G3 computer.
The method of removing duplicates and reordering the es6 array:
1. Remove repeating elements from the array
1) you can use the Array.from (new Set (arr)) statement
Var arr = [1, 2, 3, 2, 3]; console.log (arr); console.log (Array.from (new Set (arr)
2) you can use [... New Set (arr)] statement
Var arr = [5 new Set 2 (arr)]; console.log (newArr)
2. Reorder the deduplicated array
You can sort using the sort () method.
The sort () method is used to sort the elements of the array.
The sort order can be alphabetic or numeric, in ascending or descending order. The default sort order is ascending alphabetically.
NewArr.sort (); console.log (newArr)
At this point, the study of "how to remove repetition and reorder the es6 array" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.