官术网_书友最值得收藏!

Analyzing set and map types

Before actually using sets and maps, we will need to understand when and where we need to use them. Each data structure whether native or custom has its own strengths and weaknesses. 

Not only is it important to utilize these strengths, it's much more important to avoid their weaknesses. To understand some of these, we will explore set and map types and why they are needed and where to employ them. 

There are primarily four different set and map types:

  • Map: A key-value pair in which the key can either be an Object or a primitive and can hold any arbitrary value.
  • WeakMap: A key-value pair in which the key can only be an Object and can hold any arbitrary value. The Keys are weakly referenced; this means that they are not prevented from being garbage-collected if not in use.
  • Set: Data type that allows a user to store unique values of any type.
  • WeakSet: Similar to set, but maintains a weak reference.
主站蜘蛛池模板: 晋中市| 比如县| 司法| 安义县| 连城县| 仪征市| 柳河县| 车险| 临澧县| 莱阳市| 太原市| 丰都县| 庆元县| 彭阳县| 天峻县| 长顺县| 彰化县| 玛沁县| 大理市| 霍城县| 北碚区| 陇川县| 梁河县| 岑巩县| 余干县| 平度市| 宜阳县| 东乌珠穆沁旗| 富平县| 龙泉市| 井陉县| 福清市| 扎囊县| 安达市| 双牌县| 云林县| 永登县| 木兰县| 哈尔滨市| 汝阳县| 宽城|