Open Bug 1931894 Opened 1 year ago Updated 1 year ago

Show [[scopes]] when viewing a function in the console or debugger

Categories

(DevTools :: Debugger, enhancement, P3)

enhancement

Tracking

(Not tracked)

People

(Reporter: jrmuizel, Unassigned)

References

(Blocks 1 open bug)

Details

In Chrome if I run the following code:

    function f() {
        var p = 0;
        return { inc: function () { p++ }, get: function() { return p }}
    }
    var o = f();

I can inspect o and it will show me:

{inc: ƒ, get: ƒ}
 get: ƒ ()
  arguments: null
  caller: null
  length: 0
  name: "get"
  prototype: {}
  [[FunctionLocation]]: scopes.html:4
  [[Prototype]]: ƒ ()
  [[Scopes]]: Scopes[2]
   0: Closure (f) {p: 1}
   1: Global {window: Window, self: Window, document: document, name: '{"zlnd_t_tid":"9V2dB4ikSLnGKWKJ_xnEW"}', location: Location, …}
 inc: ƒ ()
 [[Prototype]]: Object

And I can see the value of the closed over p variable without having to be stopped in the debugger in inc or get

This would be helpful when debugging bug 1923825 where there's a lot of closures holding state.

See Also: → 1923825
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.