Why JavaScript const
works same as let
in for in
loop? const
is using to declare constants in EC6. Then why the const num
value getting updated in each iteration of the for in
?
For in with let
for (let num in nums) {
console.log(num); // works well, as usual
}
For in with const
for (const num in nums) {
console.log(num); // why const value getting replaced
}