Debugging
Beyond console.log(), every browser's developer tools include a real
debugger — set a breakpoint by clicking a line number in the
"Sources" tab, or add the debugger; statement directly in code:
function calculateTotal(prices) {
debugger; // execution pauses here when devtools are open
return prices.reduce((sum, p) => sum + p, 0);
}
While paused, you can inspect every variable currently in scope, and step through the code one line at a time.