JavaScript's conditional breakpoints / breakpoints in the script ( inline breakpoints )

Introduction:
Conditional breakpoints
are extemely easy do implement in JavaScript, and have been part of the ECMAScript  design from the very beginning. The keyword for setting a breakpoint is debugger; yet seems to be rarely used.

Unlike Python (as outlined nicely by Ayman Hourieh), no fancy code control is possible in JavaScript.  You really get what you see. Period, or rather semicolon. You cannot pass or set anything beyond the keyword debugger; nor can you call debugger(...); like a function as is the case with void. Note, that I also haven't found yet a fast way to quickly disassemble various JITed JavaScript code (This process is somewhat cumbersome to do in Google's V8 engine, and more convenient with Mozilla's Spidermonkey-engine: disfile(...); I will delve into this topic in another post, revealing some unplayed performance-cards).

Code Example:
Assume a very primitive and simple parser, whose only function is to check for the correctness of the character set and calculate a checknumber. (In principle the string is parsed as a first order Markov-chain.)


If you were wondering what a simple debugger; statement in Chrome's JS-console would do...here it is ↑↑

LihatTutupKomentar