javascript - 如何从 <function scope >'s Closure in Chrome Developer tool' s Watch 面板访问值?

标签 javascript html google-chrome debugging google-developer-tools

我有一个复杂的 javascript 对象,它是由一些第三方工具生成的,它看起来像这样(在 Chrome 开发者工具观察面板内):

access values from <function scope>'s Closure in Chrome Developer tool's Watch pane

我有兴趣阅读那些 textvalue i 的属性目的。 我从没见过这样的<function scope>之前的事情。在这种情况下,

How to access values from <function scope>'s Closure in Chrome Developer tool's Watch panel?

还是不可能?

最佳答案

A closure is a special kind of object that combines two things: a function, and the environment in which that function was created. The environment consists of any local variables that were in-scope at the time that the closure was created.

来源: MDN Closures

您看到的 i 对象是在过去的某个时间点创建的,您暂停的函数是在创建该对象的同一个外部函数中创建的。当内部函数访问外部函数的变量时,会创建一个闭包来“记住”它们。

您不能直接访问封闭变量。

关于javascript - 如何从 <function scope >'s Closure in Chrome Developer tool' s Watch 面板访问值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38326897/

相关文章:

jquery - Google Chrome 中使用 jQuery 的动画工件(红/蓝移)

javascript - 如何覆盖 AG Grid 中的内置 Excel 导出功能

javascript - 使用 Javascript 设置 Cookie 并清理值

javascript - Angular 6 + Universal Karma 测试导入模块

javascript - Firefox 3 中的某种 JavaScript 任务管理器?

html - 使用 Rails 和 Bootstrap 在导航栏中链接

javascript - 如何使用 Puppeteer 或 Chrome 控制台以编程方式切换 JS 上下文(到不同域的 iframe 上下文)

google-chrome - Chrome 浏览器可以打开本地链接吗?

jQuery 背景动画初始不透明度仅在 IE 中错误

javascript - 通过表单提交在 HTML5 canvas 上保存框的坐标