Breaking point

This will be a very short post about a thing that is only useful sometimes, but then when it is useful, it can be very much so.
This is how to set a breakpoint programmatically, in your browser, for debugging your javascript.
Why would you need that when you have a debugger console?
Well, a couple of cases:

  • There’s a 100 documents on the page and only one is rendered wrong. How often will you press F8 a hundred times just to mutter “oh crap passed it!” do you think?
  • There is a complicated condition when you want this breakpoint to work; too complicated to write a short conditional expression for the browser breakpoint on context click.

So, how do you do it? Simple:

    // your code...
    if (complicatedCondition) {
        debugger;
    }

This is it!

Advertisements

About Maryna Cherniavska

I have productively spent 10+ years in IT industry, designing, developing, building and deploying desktop and web applications, designing database structures and otherwise proving that females have a place among software developers. And this is a good place.
This entry was posted in javascript and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s