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

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.
主站蜘蛛池模板: 青川县| 孟连| 河南省| 镇赉县| 浏阳市| 曲水县| 柳江县| 武陟县| 新邵县| 茌平县| 和龙市| 江源县| 江源县| 油尖旺区| 甘泉县| 康乐县| 南部县| 沂水县| 本溪市| 高陵县| 武宣县| 望城县| 星子县| 吴江市| 塘沽区| 类乌齐县| 方正县| 始兴县| 马边| 利川市| 方城县| 海口市| 克东县| 中宁县| 修武县| 韶山市| 浠水县| 湛江市| 罗平县| 仙游县| 图木舒克市|