The constant defined by const is variable in the for loop.

for(let a = 1; a < 5; aPP){
    const b = a;
    console.log(b) // 1 2 3 4 undefined
}

Why for can const be reassigned within the loop?

Thank you!

May.22,2021

when the for loop ends, the life cycle of constant b ends. In the next for cycle, a new constant b


block scope and life cycle

is added.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3b7e1-2c2c7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3b7e1-2c2c7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?