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

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.
主站蜘蛛池模板: 鹤峰县| 屯门区| 和顺县| 绥江县| 普定县| 沅陵县| 仙桃市| 兰西县| 中阳县| 兰州市| 铜梁县| 慈利县| 苍山县| 平顺县| 湖口县| 华池县| 进贤县| 宜宾市| 永和县| 华蓥市| 景宁| 平顶山市| 肇源县| 綦江县| 手游| 松溪县| 永昌县| 鄯善县| 县级市| 通辽市| 武强县| SHOW| 丁青县| 千阳县| 新源县| 台东市| 左贡县| 资阳市| 微山县| 兖州市| 新巴尔虎右旗|