問題描述
一個 javascript WeakMap (
是否有可能以某種方式循環訪問條目?
不,正如您所說,WeakMap
的內容無法通過設計訪問,并且沒有可迭代性.
如果不是……Chrome 控制臺如何做到這一點?
控制臺使用 JS 引擎的調試 API,它允許訪問對象的內部(也可以訪問承諾狀態、包裝的原語等)等等.
A javascript WeakMap ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap ) does not allow you to get the key, or the length or size, by design.
Is it possible to nevertheless loop over entries in some way ?
If not .. how does the Chrome console do this ?
Is it possible to nevertheless loop over entries in some way?
No, as you say, the contents of a WeakMap
are not accessible by design, and there is no iterability.
If not … how does the Chrome console do this?
The console uses the debugging API of the JS engine, which allows access to the internals of objects (also to promise states, wrapped primitives, etc.) and many more.
這篇關于如何迭代弱圖?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!