DEV Community

Discussion on: Const is applicable on For of Loops but not on For Loops (Why)

Collapse
 
amiceli profile image
amiceli

For exemple with a for loop

for (const i = 0; i < 100; i++) {
// ....
}

You can't useconst because I++ will increment i.
But i is a constant. A constant can't change. So you have to use let

I don't know all details for for of loop, just it uses Iterator. I found a good article about loops details : exploringjs.com/es6/ch_for-of.html

Collapse
 
sojinsamuel profile image
Sojin Samuel

Thanks 4 investing the time for helping me out amiceli