[英]How to access values from <function scope>'s Closure in Chrome Developer tool's Watch panel?
I have a complex javascript object which is generated by some third party tool , which looks like this (inside Chrome Developer Tools Watch panel):我有一个复杂的 javascript 对象,它是由一些第三方工具生成的,它看起来像这样(在 Chrome Developer Tools Watch 面板中):
I'm interested in reading those text
and value
attributes of i
Object.我有兴趣阅读
i
Object 的那些text
和value
属性。 I've never seen such <function scope>
thing before.我以前从未见过这样的
<function scope>
东西。 In such cases,在这种情况下,
How to access values from
<function scope>
's Closure in Chrome Developer tool's Watch panel?如何在 Chrome Developer tool 的Watch面板中从
<function scope>
的Closure访问值?
Or is it not possible?或者不可能?
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.
环境由创建闭包时在范围内的任何局部变量组成。
Source: MDN Closures来源: MDN 关闭
The i
object you are seeing was created at some point in the past, and the function you have paused in was created within the same outer function that created the object.您看到的
i
对象是在过去的某个时间点创建的,而您暂停的函数是在创建该对象的同一个外部函数中创建的。 When the inner function accesses the variables of the outer function, a closure is created to "remember" them.当内部函数访问外部函数的变量时,会创建一个闭包来“记住”它们。
You can't access the closed over variables directly.您不能直接访问已关闭的变量。
You can change a Date value like this:您可以像这样更改日期值:
(confirmed in Chrome verion 88) (在 Chrome 88 版中确认)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.