javascript - WeakMap
天蓬老师
天蓬老师 2017-04-11 12:20:44
0
1
281
  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},各位赐教

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

membalas semua(1)
巴扎黑

你这问题好比:
var a={id:1};
b=a;
a=null;
console.log(b);

Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan