Maison > Questions et réponses > le corps du texte
const weakm = new WeakMap();
let keyObject = {id : 1};
const valObject = {score : 100};
weakm.set(keyObject,valObject);
console.log(weakm.get(keyObject));
keyObject = null;
console.log(weakm);
console.log(weakm.get(keyObject));
打印结果:
为什么打印weakm还有键 {id:1},各位赐教