0

Is there a way to stop the execution of a script when a variable (say, an iterator like 'i'), changes its value?

Of course, I know you can set a breakpoint at some lines, but I would want just to set a variable, and when it changes, stop the program for debuggin.

2 Answers 2

1

Try to use debugger, something like:

function testDebugger() {
  var i = 10;
  while(i--) {
    if (i === 5) debugger;
    Logger.log(i);
  }
}

Remember to start from the editor, with "Debug" and not "Run".

Sign up to request clarification or add additional context in comments.

Comments

0

Its not possible. However if you use a wrapper like a setValue method you can do as the answer above me, or throw "hello" and it will break into the debugger too.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.