如何在Chrome Developer工具的Watch面板中访问< function scope>的Closure中的值? [英] How to access values from <function scope>'s Closure in Chrome Developer tool's Watch panel?

查看:287
本文介绍了如何在Chrome Developer工具的Watch面板中访问< function scope>的Closure中的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有复杂的JavaScript对象,它由一些第三方工具生成,看起来像这样(在Chrome开发人员工具监视面板中):

b
$ b



我有兴趣阅读 i 文本属性c>对象。
我从来没有见过这样的< function scope> 之前的事情。在这种情况下,


如何访问< function scope>中的值' Chrome开发者工具的观看面板中的关闭吗?

可能吗?

解决方案


闭包是一种特殊的对象,它结合了两件事:以及创建该功能的环境。环境由创建闭包时在范围内的任何局部变量组成。


来源: MDN Closures


$ b $ i 你看到的对象是在过去的某个时刻创建的,并且暂停的功能是在创建该对象的相同外部函数内创建的。当内部函数访问外部函数的变量时,会创建一个闭包来记住它们。



您无法直接访问已关闭的变量。

p>

I have a complex javascript object which is generated by some third party tool, which looks like this (inside Chrome Developer Tools Watch panel):

I'm interested in reading those text and value attributes of i Object. I've never seen such <function scope> thing before. In such cases,

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

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

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. 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.

这篇关于如何在Chrome Developer工具的Watch面板中访问&lt; function scope&gt;的Closure中的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆