I'm using Chrome's (v21) dev tools to debug a large javascript application. While stepping through the code, I'd like to change the value of a local (function scope) variable. How do I do this?
I've tried:
- Clicking on the variable in the "Scope" window and editing it, hitting Enter afterward. The value changes in the Scope window as expected, but when I step to the next line, the variable then reverts back to its old value.
- Typing "variable = 123" in the console. After I hit Enter, the console "result" is the value I entered, but the variable itself does not change in value. If I then enter "variable" and hit Enter, the console returns the original value; the Scope window also shows the original value still.
Again, this is a local, function-scoped variable, and the current line of execution is within the same scope where the variable was defined.
This other question is essentially a duplicate, but hasn't elicited any useful answers (maybe because it's poorly written).
immediate window
in Visual Studio. Can verify that Chrome v22 is the same. Have you looked through the Chrome bug reports to see if there's something along these lines reported? I'm sure it isn't a 'bug' per se... more just 'non-intuitive behavior' – Pentylenetetrazol