Thuta Learning
IntermediateProgrammingbeginner

Debugging Techniques

Relax. We'll talk through this in plain words — no textbook voice.

Debugging is the process of finding and fixing bugs in your code.

🔍 Debugging Tools:

console.log(): Print values

console.table(): Display arrays/objects

debugger: Set breakpoints

Browser DevTools: Inspect, debug

console.trace(): Stack trace

javascript
// 1. console methods
const user = { name: "Aung Kyaw", age: 25, city: "Yangon" };
console.log("User:", user);
console.table(user);

// 2. Debugging with console.trace()
function first() {
    second();
}
function second() {
    console.trace("Trace from second()");
}
first();

// 3. Using debugger statement (pauses execution in DevTools)
function calculate(x, y) {
    // debugger; // Uncomment to pause here
    return x * y;
}
console.log("Result:", calculate(5, 3));

// 4. Conditional logging
const DEBUG = true;
function debugLog(message) {
    if (DEBUG) console.log(`[DEBUG]: ${message}`);
}
debugLog("This is a debug message");
You should see
User: {name: "Aung Kyaw", age: 25, city: "Yangon"} ┌─────────┬────────────────┐ │ (index) │ Values │ ├─────────┼────────────────┤ │ name │ 'Aung Kyaw' │ │ age │ 25 │ │ city │ 'Yangon' │ └─────────┴────────────────┘ Result: 15 [DEBUG]: This is a debug message
Debugging Techniques | Thuta Learning