Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show values instead of getter/setter functions in Firefox DevTools variable view

When inspecting a JavaScript object, that uses getter/setter functions for properties (defined with Object.defineProperties) in the Firefox DevTools variables view, it shows the defined getter and setter functions for this particular property:

enter image description here

Is there any way to show the actual content instead of the functions in this view?

Edit: as nils commented, viewing the actual content means technically invoking the getter.

like image 380
Marc Avatar asked Jul 26 '16 07:07

Marc


People also ask

How do I enable developer options in Firefox?

You can open the Firefox Developer Tools from the menu by selecting Tools > Web Developer > Web Developer Tools or use the keyboard shortcut Ctrl + Shift + I or F12 on Windows and Linux, or Cmd + Opt + I on macOS.

How do I see JavaScript code in Firefox?

You can open the Browser Console in one of two ways: from the menu: select “Browser Console” from the Web Developer submenu in the Firefox Menu (or Tools menu if you display the menu bar or are on macOS). from the keyboard: press Ctrl + Shift + J (or Cmd + Shift + J on a Mac).

Does a getter have a return type?

Getter returns the value (accessors), it returns the value of data type int, String, double, float, etc.

What are getter and setter methods in JavaScript?

In JavaScript, accessor properties are methods that get or set the value of an object. For that, we use these two keywords: get - to define a getter method to get the property value. set - to define a setter method to set the property value.


1 Answers

Since Firefox 65 this is possible to invoke a getter via a button next to it within the logged object.

Button to invoke a getter

This was implemented in bug 820878 resp. issue 6140 on GitHub.

In versions prior to Firefox 65 you could output the getter's return value by simply calling it directly via the command line.

like image 74
Sebastian Zartner Avatar answered Sep 30 '22 09:09

Sebastian Zartner