function example() {
    if (true) {
        var x = 10;
    }
    console.log(x); // 10 — accessible outside the if-block
}
console.log(x); // undefined
var x = 5;
if (true) {
    let y = 20;
}
console.log(y); // ReferenceError
let z = 5;
z = 10; // OK
let z = 15; // SyntaxError
const obj = { name: "Alice" };
obj.name = "Bob"; // OK
obj = { name: "Charlie" }; // TypeError
// Using var
for (var i = 0; i < 3; i++) {
    setTimeout(() => console.log(i), 1000); // prints 3, 3, 3
}

// Using let
for (let i = 0; i < 3; i++) {
    setTimeout(() => console.log(i), 1000); // prints 0, 1, 2
}