12

I would like to be able to edit a variable after setting (and hitting) a breakpoint, in either Firefox or Firefox Developer Edition.

It seems that it used to have this feature, but it was removed when the debugger was reimplemented.

There used to be a way to get the old debugger back, but I have tried this and it no longer works.

I will accept answers that recommend addons.

2 Answers 2

7

The way I do it is to simply type the new variable into the debug console with the new value. For example, I would type: myobj.myprop = newval;Enter. No different from writing javascript. As long as the variable you are trying to change is in scope at your break point (and not initialized with const), it should work fine.

1
  • It looks like it is not working, for example with the code codepen.io/iksdatoo/pen/JbbQoz if we set a breakpoint on the first button click event function at line React.createElement('button', {, then execute this.clickMe = null; in the console when the execution is stopped at the breakpoint and then resume, the function is still executed when clicking on the button.
    – baptx
    Nov 19, 2022 at 19:54
0

Create a Watch Expression for the variable. When the breakpoint hits, double-click the variable in the watch expressions list to get an editable field. Type in an assignment statement, e.g., myVar=newValue. It works with or without a semicolon.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .