Allow re-assigning of const value in DevTools

1,127 views
Skip to first unread message

Luke Vo

unread,
Aug 17, 2019, 7:50:56 AM8/17/19
to Chrome DevTools
Relevant post on StackOverflow

I understand that a const value is not meant to be reassigned, however consider DevTools is meant to tweak around values while debugging, I think there should be a quick way to try out values.


Let say in app.js:

const foo = 5;


In the console, I tried re-assigning it in the console foo = 6;

Obviously it does not work (Assignment to constant variable). I have also tried delete(window.foo)but the value still persist even though the delete function returns true.


Currently the workaround is using Local Overrides (and have to setup persistent file system) since live-editing won't work (the value is already there and without Local Overrides, the edited value does not survive a reload).

PhistucK

unread,
Aug 17, 2019, 10:19:16 AM8/17/19
to Google Chrome Developer Tools
You can actually do that, just not using the console.
If you have a breakpoint before the code that uses the value that you want to change, let it hit and then double click on the value of the variable under the Scope drawer and edit it.
image.png

PhistucK


--
You received this message because you are subscribed to the Google Groups "Chrome DevTools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/cf0b84b8-cb32-4bd3-a657-f1e2bd893fc2%40googlegroups.com.

Luke Vo

unread,
Aug 17, 2019, 10:22:45 AM8/17/19
to Chrome DevTools
Thanks, this works.


On Saturday, August 17, 2019 at 9:19:16 PM UTC+7, PhistucK wrote:
You can actually do that, just not using the console.
If you have a breakpoint before the code that uses the value that you want to change, let it hit and then double click on the value of the variable under the Scope drawer and edit it.
image.png

PhistucK


On Sat, Aug 17, 2019 at 2:50 PM Luke Vo <dat...@gmail.com> wrote:
Relevant post on StackOverflow

I understand that a const value is not meant to be reassigned, however consider DevTools is meant to tweak around values while debugging, I think there should be a quick way to try out values.


Let say in app.js:

const foo = 5;


In the console, I tried re-assigning it in the console foo = 6;

Obviously it does not work (Assignment to constant variable). I have also tried delete(window.foo)but the value still persist even though the delete function returns true.


Currently the workaround is using Local Overrides (and have to setup persistent file system) since live-editing won't work (the value is already there and without Local Overrides, the edited value does not survive a reload).

--
You received this message because you are subscribed to the Google Groups "Chrome DevTools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-developer-tools+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages