+ 1
Const decleration in a loop
How is it possible to use const in a for of loop .. for (const digit of digits){ whatever } Even though the value of digit in this example gets updated everytime the code runs a.k.a every time the next() functions is called inside the iterator object
4 ответов
+ 1
Got the answer guys nevermind .. it is the block of code that gets created at every loop run, with every run the variable is declared from scratch, every run is a separate block, separate scope
" Const has a block scope just like let.
Therefore, a new const is created at each iteration of the loop.
This const can't be redefined in the iteration itself." Elena
+ 1
Yes. But where you seen gets updated..? It warns error.
Can you post it for clarity....
0
Notice that const declarations cannot be updated (reassigned)
0
Yes. That why I asked for code snippet..