标签:用法 时间 清空 for foreach people value 删除 fun
// weakSet 基础用法 let jelly = {name:‘jelly‘,age:20}; let mary = {name:‘mary‘,age:25}; const weakPeople = new WeakSet([jelly,mary]) console.log(weakPeople) mary = null //什么时间回收和各自的浏览器有关系。务必注意 console.log(weakPeople)
// Map 基础用法 const people = new Map(); people.set(‘Jelly‘, 23); people.set(‘Ted‘, 23); people.set(‘Mary‘, 23); people.set({},3); people.get(‘Jelly‘) //23 console.log(people.size) //4 people.has(‘Jelly‘) //true people.delete(‘Jelly‘)--删除Jelly //people.clear() //清空 people.forEach(function(value,key,map){ console.log(value,key,map) })
……
标签:用法 时间 清空 for foreach people value 删除 fun
原文地址:https://www.cnblogs.com/jwzhang/p/12113046.html