我有一个复杂的 javascript 对象,它是由一些第三方工具生成的,它看起来像这样(在 Chrome 开发者工具观察面板内):
我有兴趣阅读那些 text
和 value
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/