Alberto
Alberto

Reputation: 12949

"Debug" function in Chrome

probably a silly question, but somehow i ended up on the debug function available in Google Chrome Console, which if i try to print it on the console i get:

ƒ debug(function, condition) { [Command Line API] }

however i'm totally unable to console.log something from it in any way, and I can't find any documentation online...
I've tested it on Firefox and i get Uncaught ReferenceError: debug is not defined so it's not cross platform, but maybe for development purpose it might be helpful

Maybe is related to debugger;?...

Upvotes: 5

Views: 1887

Answers (1)

Bergi
Bergi

Reputation: 665286

This is documented in the Console Utilities API Reference:

debug(function)

When the specified function is called, the debugger is invoked and breaks inside the function on the Sources panel allowing to step through the code and debug it.

debug(getData);

Use undebug(fn) to stop breaking on the function, or use the UI to disable all breakpoints.

For more information on breakpoints, see Pause Your Code With Breakpoints.

Upvotes: 6

Related Questions