0

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.

GreenGiant
  • 4,930
  • 1
  • 46
  • 76
AbstractDissonance
  • 1
  • 2
  • 16
  • 31
  • possible duplicate of [Is it possible to change javascript variable values while debugging in Google Chrome?](http://stackoverflow.com/questions/4603021/is-it-possible-to-change-javascript-variable-values-while-debugging-in-google-ch) – gilly3 Oct 23 '12 at 17:01
  • Already implemented in V8: [Issue 2399](http://code.google.com/p/v8/issues/detail?id=2399) Now Chromium's Developer Tools need to be updated: [Issue 124206](http://code.google.com/p/chromium/issues/detail?id=124206) – gabrielmaldi Mar 21 '13 at 17:52

2 Answers2

2

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

Alexander Pavlov
  • 31,598
  • 5
  • 67
  • 93
1

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

Mogsdad
  • 44,709
  • 21
  • 151
  • 275