javascript - How to get the value of the [[entries]] attribute of the Map object in js?
大家讲道理
大家讲道理 2017-06-30 09:59:04
0
2
1021

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(2)
女神的闺蜜爱上我
var m = new Map();
m.entries();
给我你的怀抱

cannot be accessed directly. This value is actually a mapping of [[Entries]] within entries(), but there is a key => map array inside, which can be obtained using the following methods.

Method 1

var arr = [];
var map = new Map();
for(var [key, val] of map.entries()) {
    arr.push([key, val]);
}

Method 2

var map = new Map();
Array.from(map);

The arrays output by the above two methods are similar:

[
    [1, 'a'],
    [2, 'b']
]

The first of each item is the key name, and the second is the key value.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template