当前位置:网站首页>Difference between map and object
Difference between map and object
2022-06-24 20:29:00 【Gentle breeze - grass】
Map Follow object The difference between
| Map | Object | |
|---|---|---|
| Unexpected key value | Map By default, there are no keys | Object There's a prototype , The key name on the prototype chain may conflict with the setting key name of your own object |
| Type of key | Map The bond of can be any value , Include functions , Object or any basic type | Object Must be String perhaps Symbol |
| The order of the keys | Map Of Key Is ordered . So in iterations Map In the order in which the objects are inserted | Object Is chaotic |
| Size | Map The key value logarithm of can be easily passed through Size Property acquisition | Object The number of key value pairs of can only be calculated manually |
| iteration | Map yes iterable Of , So it can be iterated directly | iteration Object You need to get its key in some way before you can iterate |
| performance | It performs better in the scenario of frequent addition and deletion of key value pairs | In the scenario of frequent addition and deletion of key value pairs, no optimization is made |

Map The data structure has the following operation methods :
- size: map.size return Map The total number of members of the structure .
- set(key,value): Set the key name key Corresponding key value value, Then go back to the whole Map structure , If key There has been a value , Then the key value will be updated , Otherwise, the new key will be generated .( Because it returns the current Map object , So you can chain call )
- get(key): This method reads key Corresponding key value , If you can't find it key, return undefined.
- has(key): This method returns a Boolean value , Indicates whether a key is currently Map In the object .
- delete(key): This method deletes a key , return true, If the deletion fails , return false.
- clear():map.clear() Clear all members , no return value .
Map Structure native provides three ergodic generator functions and one ergodic method
- keys(): Returns the traverser of the key name .
- values(): The traverser that returns the key value .
- entries(): Returns the traverser of all members .
- forEach(): Traverse Map All members of .
边栏推荐
- Open programmable infrastructure (OPI) project, redefining dpu/ipu
- Predicate
- The Network Security Review Office launched a network security review on HowNet, saying that it "has a large amount of important data and sensitive information"
- Why is the executor thread pool framework introduced
- Database index can improve query efficiency. Ask what will improve, what is the difference between inapplicable index and index use, and what will happen.
- [go Language brossage] go from 0 to Getting started 4: Advanced use of slice, Primary Review and Map Getting started Learning
- 【CANN文档速递06期】初识TBE DSL算子开发
- 1、 Downloading and installing appium
- It is said that Tencent officially announced the establishment of "XR" department to bet on yuanuniverse; Former CEO of Google: the United States is about to lose the chip competition. We should let T
- 微信小程序自定义tabBar
猜你喜欢

Docker installing Oracle

顺序表的基本操作

Otaku can't save yuan universe

Confirm whether the host is a large terminal or a small terminal

对“宁王”边卖边买,高瓴资本“高抛低吸”已套现数十亿

Teach you how to cancel computer hibernation

Data backup and recovery of PgSQL

实现基于Socket自定义的redis简单客户端

网络安全审查办公室对知网启动网络安全审查,称其“掌握大量重要数据及敏感信息”

【Go語言刷題篇】Go從0到入門4:切片的高級用法、初級複習與Map入門學習
随机推荐
[video tutorial] functions that need to be turned off in win10 system. How to turn off the privacy option in win10 computer
Docker installing MySQL
IP address to integer
图的基本概念以及相关定义
【CANN文档速递05期】一文让您了解什么是算子
[cann document express issue 04] unveiling the development of shengteng cann operator
Data backup and recovery of PgSQL
用手机摄像头就能捕捉指纹?!准确度堪比签字画押,专家:你们在加剧歧视
等等党们的胜利!挖矿退潮后,显卡价格全面暴跌
Teach you how to cancel computer hibernation
【云驻共创】ModelBox隔空作画 绘制你的专属画作
顺序栈1.0版本
华为云ModelArts第四次蝉联中国机器学习公有云服务市场第一!
Win7 10 tips for installing Office2010 five solutions for installing MSXML components
Information theory of popular science Shannon
Vxlan and MPLS: from data center to Metro Ethernet
Basic operation of sequence table
Bytebase joins Alibaba cloud polardb open source database community
C language to realize mine sweeping (simple version)
Microsoft Office Excel 2013 2016 graphic tutorial on how to enable macro function