Debug with browser DevTools
ECMAScript 2026
Trace the values behind a wrong result and pause code to see them at a specific point.
On this page
Trace the first wrong value
Start with the expected result and inspect one intermediate value at a time. Here Number() returns NaN because the input contains a comma. Fix the conversion after you confirm the raw value.
How to try it Open a browser tab, then open Developer Tools → Console. Type the example or paste it into the Console after reviewing it, then run it. Reload before repeating declarations with the same names.
const rawPrice = "2,500";
const price = Number(rawPrice);
console.log("Raw:", rawPrice, "Parsed:", price);
console.log("Total:", price * 2);
What to expect Run once to see NaN. Change "2,500" to "2500" and run again to see 5000.
Pause at a breakpoint and step over
Open browser DevTools before clicking Total. The debugger statement pauses before the multiplication when the debugger is active. Inspect quantity and price in Scope, then select Step over to execute the next line. In a saved file, you can replace debugger with a line breakpoint by clicking a line number in Sources.
How to try it Save this example as a new .html file, then open it in your browser. After a change, save and reload.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Pause at a breakpoint and step over</title>
</head>
<body>
<button id="total">Total</button>
<p id="result"></p>
<script>
document.querySelector("#total").addEventListener("click", () => {
const quantity = 2;
const price = 1500;
debugger;
const total = quantity * price;
document.querySelector("#result").textContent = total + " MMK";
});
</script>
</body>
</html>
What to expect When paused, quantity is 2 and price is 1500. Resume to see 3000 MMK. With DevTools closed, Total displays the result immediately.