list,map,set,数组,对比
map
前端
- let map = new Map([
[1, ‘one’],
[2, ‘two’],
[3, ‘three’],
]);
let arr = […map.keys()]; // [1, 2, 3]
遍历:
map.forEach(function(value,key){console.log(value,key);});
for(let item of map){ }
for(let item of map.keys()){
for(let item of map.values()){
for(let item of map.entries()){ }
dart
- var gifts = {
// Key: Value
‘1’: ‘one’,
‘2’: ‘two’,
‘3’: ‘three’
}; - var gifts = Map();
gifts[‘1’] = ‘one’;
gifts[‘2’] = ‘two’;
gifts[‘3’] = ‘three’;
java
-
Map<String, String> map = new HashMap<String,String>();
//给map中添加元素
map.put(“1”, “one”);
map.put(“2”, “two”);遍历: for(Map.Entry<S