Debugging is the diagnostic discipline of identifying, isolating, and rectifying defects in computer software. Professional JavaScript engineers rely on browser Developer Tools rather than simple console.log() statements to analyze memory states and step through execution lines.
// 1. console.table() - Renders arrays/objects in beautiful readable tables
const students = [
{ id: 101, name: "Vikram", marks: 92 },
{ id: 102, name: "Pooja", marks: 88 },
{ id: 103, name: "Rahul", marks: 95 }
];
console.table(students);
// 2. console.time() and console.timeEnd() - Benchmarking performance
console.time("LoopPerformance");
let sum = 0;
for (let i = 0; i < 1000000; i++) sum += i;
console.timeEnd("LoopPerformance"); // Outputs: LoopPerformance: 2.14ms
// 3. console.trace() - Prints the complete Call Stack trace to this point
function deeplyNestedFunc() {
console.trace("Where was I called from?");
}
Inserting the debugger; statement freezes browser execution at that line, launching DevTools automatically:
function calculateTax(income) {
debugger; // Browser pauses here if F12 DevTools is open!
let rate = (income > 500000) ? 0.2 : 0.05;
return income * rate;
}
calculateTax(750000);
DevTools Stepping Controls:
Congratulations on completing Tier 2: Control Flow & Loops! Now let us explore collections and memory structures. Proceed to Tier 3: JavaScript Arrays & Index Traversal →
Accelerate your JavaScript mastery by studying these tightly connected core tutorials:
Defensive coding and error throwing.
Mastering the browser developer console.
Using the Chrome performance profiler.