In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the es6 expansion operator can be repeated related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that you can read this es6 expansion operator can go to the article will have a harvest, let's take a look.
In es6, the extension operator "..." is used alone. Can not be deduplicated, can be used with the Set object to carry out array deduplication. Deduplication method: 1, use the "new Set (arr)" statement to convert the array to the Set collection type, and use the Set feature to remove repetitive elements; 2, use the "[... collection]" statement to convert the deduplicated Set collection into an array.
The operating environment of this tutorial: windows7 system, ECMAScript version 6, Dell G3 computer.
In es6, use the extension operator "..." alone. Can not be deduplicated, can be used with the Set object to carry out array deduplication.
Set is a new data structure provided by ES6, which is similar to an array, but does not have duplicate values. With this feature, we can convert the array to the Set type for deduplication, and then use the Array.from method to convert it back to the array.
Extension operator... It is introduced in ES6 to expand iterable objects into their separate elements. The so-called iterable objects are any objects that can be traversed by for of loops, such as arrays, strings, Map, Set, DOM nodes, and so on.
Realize the idea:
After converting the array to the set collection to remove duplicates, use the extension operator. Expand the collection into an array and convert the collection to an array
Implementation code:
Let arr= [1, 2, 3 new Set 3 arr 2, "1", 0 undefined new Set undefined]; console.log (newArr)
This is the end of the article on "can the es6 extension operator be duplicated?" Thank you for reading! I believe you all have a certain understanding of the knowledge of "can the es6 extension operator be de-duplicated". If you want to learn more, you are welcome to follow the industry information channel.
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.