1

I am trying to debug code with Chrome Dev Tools.

I want to find the line of code when let's say x became null.

I've started using the Watch Expression feature, which helps, but I still need click line by line to make the code slowly execute while keeping my eyes on the watched expression. I also have to decide each time whether to "step into" or "step over". I keep missing the breaking point and I have to do it all over again.

Is there a way to let the code run and automatically stop when my watched expression has changed value?

Nathan H
  • 48,033
  • 60
  • 165
  • 247
  • At a specific line of code, or *anywhere*? The former is possible, I'm not sure the latter is in Chrome's dev tools... – T.J. Crowder May 21 '15 at 10:46
  • you could implement object mutators. – Daniel A. White May 21 '15 at 10:47
  • Anywhere - I am trying to find the line of code that turned my var to null. I'm open to other tools outside of chrome dev tools of course. – Nathan H May 21 '15 at 10:47
  • Is it possible to use a function to set x and test the new value each time and then step out or get a stack trace using an Error? – Dave Pile May 21 '15 at 11:10
  • possibly a duplicate of [Chrome JavaScript Debugging: how to break when a value changes](http://stackoverflow.com/q/13291814/710446) – apsillers May 21 '15 at 12:46
  • I saw that question but because his question related to `console` all the answers were specific to `console`. – Nathan H May 21 '15 at 12:47
  • @NathanH The first paragraph of my answer explains why my solution does *not* work for `console`, but works for any other property. – apsillers May 21 '15 at 12:51
  • The variable is not a public property but a private var. If I turned my var into a property, wouldn't it mean I need to look for every use of the var and change it to a property call? Also, I actually don't have easy access to the source code, I can't make changes and save my changes. – Nathan H May 21 '15 at 13:31

0 Answers0