Change local variable or function parameter in google chrome

左心房为你撑大大i 提交于 2019-12-25 18:14:44

问题


I'm using chrome's devtools to debug/modify a non-local javascript file(so I can't edit it).

The code is rather complex and defines function inside of functions and uses these pointers throughout.

The point is that I do not know where I'm exactly at in the process but I can set a breakpoint to a variable I need to modify. BUT I can't figure out how to modify it. I can add a watch or modify it under the locals panel BUT it won't actually change (after stepping once the value reverts to original)

So how can I change the variable? I don't know why it is so difficult. In my traditional debugging you can simply edit the value in the watch or locals and it will modify it. I've tried modifying it at the console but I guess I don't know the complete path to the variable and I always get an undefined variable.

All I want to do is modify a local variable or argument in side some function I set a breakpoint at.


回答1:


Try doing this in the console. E.g.: window.myVar = "newValue"




回答2:


First watch the variable, second in Scope tab you can change the value of the var!



来源:https://stackoverflow.com/questions/11929215/change-local-variable-or-function-parameter-in-google-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!