admin 管理员组文章数量: 1086019
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).
Is there any easier way to quickly change a const
value?
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).
Is there any easier way to quickly change a const
value?
2 Answers
Reset to default 7The solution on Google Chrome DevTools group:
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.
const redeclaration in the console was added in Chrome 92 :)
Careful though - this is only supported across separate REPL scripts.
本文标签: javascriptIs there any way to reassign a const in Chrome DevToolsStack Overflow
版权声明:本文标题:javascript - Is there any way to re-assign a const in Chrome DevTools? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1744001201a2516476.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论