当前位置:网站首页>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 .
边栏推荐
- 基于SSM的物料管理系统(源码+文档+数据库)
- Otaku can't save yuan universe
- Error in Android connection database query statement
- Predicate
- 【Go語言刷題篇】Go從0到入門4:切片的高級用法、初級複習與Map入門學習
- 华为云ModelArts第四次蝉联中国机器学习公有云服务市场第一!
- Ribbon源码分析之@LoadBalanced与LoadBalancerClient
- Coinbase将推出首个针对个人投资者的加密衍生产品
- 2022年最新四川建筑八大员(电气施工员)模拟题库及答案
- RF_ DC system clock setting gen1/gen2
猜你喜欢

Using dynamic time warping (DTW) to solve the similarity measurement of time series and the similarity identification analysis of pollution concentration in upstream and downstream rivers

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

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

What is CNN (convolutional neural network)

16个优秀业务流程管理工具

When querying the database with Gorm, reflect: reflect flag. mustBeAssignable using unaddressable value

Test drive citus 11.0 beta (official blog)

Why is the executor thread pool framework introduced

Making startup U disk -- Chinese cabbage U disk startup disk making tool V5.1

苹果不差钱,但做内容“没底气”
随机推荐
The latest simulated question bank and answers of the eight members (Electrical constructors) of Sichuan architecture in 2022
物联网?快来看 Arduino 上云啦
用手机摄像头就能捕捉指纹?!准确度堪比签字画押,专家:你们在加剧歧视
Apache+php+mysql environment construction is super detailed!!!
Fundamentals of performance testing -- definitions of common terms
Basic operation of sequence table
Accurate calculation of task progress bar of lol mobile game
OpenVINO2022 Dev Tools安装与使用
Clustered index (clustered index), nonclustered index (nonclustered index)
Simulation lottery and probability statistics experiment of the top 16 Champions League
Why is the executor thread pool framework introduced
视频平台如何将旧数据库导入到新数据库?
C langage pour le déminage (version simplifiée)
Openstack actual installation and deployment tutorial, openstack installation tutorial
Nodered has no return value after successfully inserting into the database (the request cannot be ended)
Dongyuhui is not enough to bring goods to "rescue" live broadcast
基于QT+MySQL的相机租赁管理系统
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
首个大众可用PyTorch版AlphaFold2复现,哥大开源OpenFold,star量破千
Bytebase joins Alibaba cloud polardb open source database community