我有一个复杂的javascript对象,它是由某些第三方工具生成的,看起来像这样(在Chrome开发者工具的“监视”面板内部):
我对阅读i Object的那些文本和值属性感兴趣.
我从未见过这样的< 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对象是在过去的某个时间创建的,而您暂停的函数是在创建该对象的相同外部函数中创建的.当内部函数访问外部函数的变量时,将创建一个闭包以“记住”它们.
您不能直接访问closed over变量.