0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

覚えておくべき前提条件

1.まず配列を作成したら、メモリに情報が格納されている
2.メモリは有限なので使わない配列はガベージコレクションという清掃員さんにて、
定期的に解放している(消している)

WeakMapの存在意義

弱い参照でオブジェクトを保持するコレクションのこと
上記のことから、バリューが使われなければ、自分で捨てればいいんじゃないの?
というのがWeakMapです。

注意点:キーは必ずオブジェクト

const wm = new WeakMap();
const o = {};
wm.set(o,'value1');
console.log(wm.get(o))
console.log(wm.has(o))

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?