Variables declared with let and const have block scope:
function example() {
if (true) {
let x = 10
const y = 20
}
console.log(x) // Error: x is not defined
}
Block scope means variables exist only within the {} where they're declared. This includes if statements, loops, and any other blocks.