Dotista
Dotista

Reputation: 431

How do I see my private class field values in Firefox debugger?

When the code pauses at a breakpoint, where in devTools are my private class variables displayed? I can see the public ones but not the privates (I mean variables prefixed with #)

class MyClass {

  #myVar;

  constructor() {
    
    this.#myVar = 'foo'
    debugger
  }
  
}


new MyClass()

Upvotes: 0

Views: 93

Answers (1)

Barmar
Barmar

Reputation: 782158

WHen you're stopped in the debugger, you can see this in the Scopes > MyClass section of the sidebar. Expanding it shows the private property #myVar: "foo".

Console debugger output

More generally, if you're not in a method of the class when you stop, you'll need a variable that contains a class instance. You can enter the variable name in the console, and its properties will be shown.

Upvotes: 0

Related Questions