Skip to content

Instantly share code, notes, and snippets.

@p01
Created January 12, 2014 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save p01/8386586 to your computer and use it in GitHub Desktop.
Save p01/8386586 to your computer and use it in GitHub Desktop.
Conditional breakpoint after X iterations of a loop
// Example of conditional breakpoint ( in code ) after X iterations
for(var i=0, __iterations_left_before_break=50; (--__iterations_left_before_break||debugger),i<1e5;i++)
{
// body of the loop
}
/*
To do the same in devtool, you can put a breakpoint on the first statement of the loop,
right-click on the breakpoint > Edit condition.
Write an expression that is truthy when you want to break, and falsy otherwise.
Be wary of trailing semicolon on the condition as it would behave as if followed by an
empty statement and thus never break ;)
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment