Why will ES6 WeakMap's not be enumerable?

后端 未结 2 2109
北海茫月
北海茫月 2020-12-05 17:58

Before my re-entry in JavaScript (and related) I\'ve done lots of ActionScript 3 and there they had a Dictionary object that had weak keys just like the upcoming WeakMap; bu

2条回答
  •  半阙折子戏
    2020-12-05 18:05

    Finally found the real answer: http://tc39wiki.calculist.org/es6/weak-map/

    A key property of Weak Maps is the inability to enumerate their keys. This is necessary to prevent attackers observing the internal behavior of other systems in the environment which share weakly-mapped objects. Should the number or names of items in the collection be discoverable from the API, even if the values aren't, WeakMap instances might create a side channel where one was previously not available.

提交回复
热议问题