Skip to content Skip to sidebar Skip to footer

How To Access Values From '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): I'm interested in reading those

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

Solution 2:

You can change a Date value like this:

  • right click on your variable in "Scope" (on the right of your source tab).
  • select "store object as global variable".
  • now you will have jumped to console and have a new global variable "temp1". (1 will increased if you repeatly doing this)
  • type temp1.setTime([your-date-value]) will change the value of it.

(confirmed in Chrome verion 88)

Post a Comment for "How To Access Values From 's Closure In Chrome Developer Tool's Watch Panel?"