当前位置:网站首页>Recognize map
Recognize map
2022-06-26 00:57:00 【ivanfor666】
/* * Map * * * */
let myMap = new Map();
let keyObj = {};
myMap.set(keyObj, " Sum key keyObj The value of the Association ");
myMap.size;
// 1 myMap.get(keyObj);
// " Sum key keyObj The value of the Association " myMap.get({});
// undefined, because keyObj !== {}
// Traverse Map
for (var [key, value] of myMap) {
console.log(key + " = " + value);
}
for (var key of myMap.keys()) {
console.log(key);
}
for (let value of myMap.values()) {
console.log(value);
}
Array.from(myMap); // [[key,value]] Array.from(myMap.keys())
// Copy or merge Maps
let one = new Map([[1, 'one'], [2, 'two'], [3, 'three'],]);
new Map(one);
// Shallow clone
let first = new Map([[1, 'one'], [2, 'two'], [3, 'three'],]);
let second = new Map([[1, 'uno'], [2, 'dos']]);
// Merge two Map Object time , If there are duplicate key values , Then the latter will cover the former .
// The expansion operator is essentially to expand Map Object to array .
let merged = new Map([...first, ...second]);
console.log(merged.get(1));
// uno console.log(merged.get(2));
// dos console.log(merged.get(3)); // three
// Please note that ! by Map It's also possible to set object properties , But it can cause a lot of confusion .
let wrongMap = new Map()
wrongMap['bla'] = 'blaa'
wrongMap['bla2'] = 'blaaa2'
console.log(wrongMap) // Map { bla: 'blaa', bla2: 'blaaa2' }
// Map Medium key Is ordered . therefore , When iterating , One Map In the order in which the objects are inserted .
// utilize Map duplicate removal
var map = new Map;
[1, 1, 22, 33, 22, 33, 11, 1].forEach(item => map.set(item, true));
map.keys()边栏推荐
- Establish a j-link GDB cross debugging environment for Px4
- How to design the product roadmap?
- DPVS fullnat mode deployment
- How product managers control the progress of product development
- 随便画画的
- Endnote IEEE Transactions on industrial electronics/tie/tpel reference format template
- flink报错:No ExecutorFactory found to execute the application
- Atlas200dk刷机
- Stream data
- Logstash discards log data that does not match the file name exactly
猜你喜欢

Compiler Telegram Desktop end (tdesktop) en utilisant vs2022

Compile the telegraph desktop side (tdesktop) using vs2022

Music spectrum display toy -- implementation and application of FFT in stm32

What are the red lines of open source that should not be trodden on?

Case: drawing Matplotlib dynamic graph

How product managers control the progress of product development

Template engine - FreeMarker first experience

FPGA notes -- implementation of FPGA floating point operation

Web學習之TypeScript

Middle order clue binary tree
随机推荐
事物/现象/事情/东西/情况/表象
mtb13_ Perform extract_ blend_ Super{candidate (primaryalternate) \u unique (nullable filtering \foreign\index\granulati
FreeRTOS+STM32L+ESP8266+MQTT协议传输温湿度数据到腾讯云物联网平台
[system architecture] - what are MDA architecture, ADL and DSSA
制作3D浪漫炫酷相册【附源码】
Modelsim simulation FFT core cannot be simulated solution (qsys)
Things / phenomena / things / things / situations / appearances
SVN
Implementation notes of least square fitting conic in stm32
Typescript for Web Learning
Compiler Telegram Desktop end (tdesktop) en utilisant vs2022
Learn to identify follow-up questions in dialogue Q & A
STM32 uses SPI mode to drive TFT-LCD optimization code of hx8347 scheme
Download and install flume
[image detection] vascular tracking and diameter estimation based on Gaussian process and Radon transform with matlab code
Daily question: the difference between threads and processes
信号处理函数内必须使用可重入函数
JS逆向案例:破解登录密码
Mining pit record of modified field information in Dameng database
Kylin