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

北战南征 提交于 2019-12-30 11:54:05

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/38326897/how-to-access-values-from-function-scopes-closure-in-chrome-developer-tools

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!