24.WeakMap

2017-10-27  本文已影响26人  dptms

WeakMap

WeakMap 是 Map 的弱引用,它也是在 Map 的基础上有了一些限制和自己的特性。

let dp = {name:dp};
let tms = {name:tms};

const strong = new Map();
const weak = new WeakMap();

strong.set(dp , 'dp is best');
weak.set(tms , 'tms is beautiful');

几种使用场景

上一篇 下一篇

猜你喜欢

热点阅读