In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail the example analysis of the Map collection in ES6. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
Map collection
Similar to objects, it is also a collection of key-value pairs, but keys are not limited to strings. Values of various types (including objects) can be used as keys.
Map also implements the iterator interface, so you can use the extension operator and for of to traverse
1 size returns the number of elements of Map
2 set adds a new element that returns the current Map
3 get returns the key value of the key name object
4 has detects whether the Map contains an element and returns a Boolean value
5 clear clears the collection and returns undefined
/ declare let m = new Map (); m.set ('name',' zhangning'); m.set ('change', function () {console.log (' get harder)}); / / key change value A function let key = {company: 'supwisdom'}; m.set (key, [1,2,3]); / / key object value array m.size / / get m m.delete ('name'); / / delete key-value pair m.get (' change'); / / get the value corresponding to the key / / m.clear (); / / clear for (let v of m) {console.log (v) } this is the end of the article on "sample analysis of Map collections in ES6". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.