Use “debugger;” in your JavaScript to trigger the browsers debug mode.

While watching the excellent course on Single Page Apps with HTML5, Web API, Knockout and jQuery by John Papa over at PluralSight, he dropped a nice little nugget of information that I was totally unaware of.

You can add debugger; as a line by itself in your JavaScript  and when your code gets executed by the browser, the browsers built in debugger will stop on that line. Think of it as a way to throw breakpoints right into your code.

Obviously this is definitely not something you would ever want to remain in production code, so be sure to use it sparingly and carefully and always remove when you are finished debugging!

Leave a Reply

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

You are commenting using your 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