for(let i =0; i<10;i++){
const a = i;
console.log(a);
}
const b = 5;
const b = 10;
for(const i =0; i<10;i++){
const a = i;
console.log(a);
}
enter code here
In above code b is declared twice so system is giving an error. Uncaught SyntaxError: Identifier 'b' has already been declared
In the for loop, the constant variable will be declared as many time as the loop runs. Why its not an error?
In the second loop why the const i throwing an error? Is const i in the for loop initialisation have a different scope?