When using a for of loop, both of these are allowed and work:
const numbers = [1,2,3];
// works
for(let number of numbers) {
console.log(number);
}
// also works
for(const number of numbers) {
console.log(number);
}
I always use const since I cannot fathom changing the number variable in any context, but when I see a for...of loop in other people's code, it often uses let. Maybe there's a drawback to const that I didn't see? Browser bugs?
Why use const and when to use let in for...of loops?