Is it possible to create a “weak reference” in javascript?

前端 未结 9 1710
忘掉有多难
忘掉有多难 2020-11-28 04:53

Is there any way in javascript to create a \"weak reference\" to another object? Here is the wiki page describing what a weak reference is. Here is another article that desc

9条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-28 05:41

    EcmaScript 6 (ES Harmony) has a WeakMap object. Browser support amongst modern browsers is pretty good (the last 3 versions of Firefox, chrome and even an upcoming IE version support it).

提交回复
热议问题