for (let i = 0; i < 5; i++) {
console.log(`Inside the loop: ${i}`);
}
console.log(`Outside the loop: ${i}`);
output:
Inside the loop: 0
Inside the loop: 1
Inside the loop: 2
Inside the loop: 3
Inside the loop: 4
and will be error:
Uncaught ReferenceError: i is not defined
because t the variable 'i' only exists and can be accessible inside the for loop block.