mirror of
https://github.com/ruanyf/es6tutorial.git
synced 2025-05-25 03:02:21 +00:00
docs(map): fix map #614
This commit is contained in:
parent
a13917f1be
commit
52e67f71da
@ -805,7 +805,7 @@ new Map([
|
|||||||
|
|
||||||
**(3)Map 转为对象**
|
**(3)Map 转为对象**
|
||||||
|
|
||||||
如果所有 Map 的键都是字符串,它可以转为对象。
|
如果所有 Map 的键都是字符串,它可以无损地转为对象。
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
function strMapToObj(strMap) {
|
function strMapToObj(strMap) {
|
||||||
@ -823,6 +823,8 @@ strMapToObj(myMap)
|
|||||||
// { yes: true, no: false }
|
// { yes: true, no: false }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
如果有非字符串的键名,那么这个键名会被转成字符串,再作为对象的键名。
|
||||||
|
|
||||||
**(4)对象转为 Map**
|
**(4)对象转为 Map**
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
Loading…
x
Reference in New Issue
Block a user