0
点赞
收藏
分享

微信扫一扫

ES6-map数据结构,增加、删除、查找 方法(set get has delete clear ) 属性:size

 

es6-map数据结构增加、删除、查找 方法(set get has delete clear ) 属性   map数据结构: 本质上是键值对的集合,类似集合; 可以遍历,方法很多,可以跟各种数据格式转换。

ES6-map数据结构,增加、删除、查找 方法(set get has delete clear ) 属性:size_数据结构

let json = {
name:'ananiah',
age:'18'
}
//效率低 需要遍历json
console.log(json.name);

ES6-map数据结构,增加、删除、查找 方法(set get has delete clear ) 属性:size_数据结构

声明map

ES6-map数据结构,增加、删除、查找 方法(set get has delete clear ) 属性:size_数据结构

//声明map
var map = new Map();
map.set(json,'web');
console.log(map) //Map(1) {{…} => "web"}
map.set('wulala',json);
console.log(map) //Map(2) {{…} => "web", "wulala" => {…}} //key: "wulala" value: {name: "ananiah", age: "18"}

ES6-map数据结构,增加、删除、查找 方法(set get has delete clear ) 属性:size_数据结构

map中增加、删除、查找 方法(set get has delete clear ) 属性:size

ES6-map数据结构,增加、删除、查找 方法(set get has delete clear ) 属性:size_数据结构

//map中增加、删除、查找 方法(set get has delete clear ) 属性:size
//get 取值
console.log(map.get(json))
//删除 delete
map.delete(json)
console.log(map)
// 删除全部
// map.clear();
//长度
console.log(map.size)
//查找 true false
console.log(map.has('ananiah')) //false

ES6-map数据结构,增加、删除、查找 方法(set get has delete clear ) 属性:size_数据结构


举报

相关推荐

0 条评论