1 let map = new Map()
 2 map.set('first','hellow')
 3 map.set('second','world')
 4 console.log(map) //Map(2) {"first" => "hellow", "second" => "world"}
 5 for (let s of map.keys()) {
 6     console.log(s)//first second
 7 }
 8 for (let s of map.values()) {
 9     console.log(s)//hello world
10 }
11 for (let s of map.entries()) {
12     console.log(s) //["first", "hellow"] ["second", "world"]
13 }

 

相关文章: