如何迭代弱图?

时间:2023-02-09
本文介绍了如何迭代弱图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个 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模板网!

上一篇:在 JavaScript ES6 中,可迭代对象和迭代器有什么区 下一篇:Javascript“流行"从对象

相关文章

最新文章