- Write debugger; as the first line inside your function.
- Inspect Element.
- Run the function in the Console and look at the Sources tab. (The ‘debugger;‘ line should be highlighted in Sources).
- ‘Step over the next function call’ to test the code line by line as it’s running.
- ‘Step into the function’ if you want to go inside the callback function that’s inside the function you’re debugging.
* Create a separate function to run the debugger on any function instead of having to write debugger; in each of our function.
function runWithDebugger (ourFunction) {
debugger;
ourFunction();
}
Advertisements