Open a page in Chrome, enter the JavaScript console, and type debugger;. Immediately we hit a breakpoint at line 2 of the following code:
with ((window && window.console && window.console._commandLineAPI) || {}) {
debugger;
}
Can anyone make sense of this? Why the with statement? Why the breakpoint on debugger;?
Do you know what debugger is?
“Invokes any available debugging functionality. If no debugging functionality is available, this statement has no effect.”
The code is basically saying if there is a console available with this browser and it has the feature “_commandLineAPI”, start up the debugger.
The “with” statement basically is a catch all way to make sure there is not an error. In reality they should have just used an if.