map为键值对集合
let m = new Map(); m.set('name', '小白'); m.set('chang', function() { console.log("改变自己"); }) let key = { school: 'NONGDA' }; m.set(key, ['beijing', 'shanghai', 'shenzhen']); console.log(m); //size console.log(m.size); //删除 m.delete('name'); //获取 console.log(m.get('chang')); console.log(m.get(key)); //晴空 m.clear(); //遍历 for (let v of m) { console.log(v); }
map其实就是一个升级版的对象
标签:ES6,set,console,log,map,let,key From: https://www.cnblogs.com/xiaobaizitaibai/p/16823990.html