Variable declaration reset: Difference between revisions
Content added Content deleted
(→{{header|JavaScript}}: added "for(i=0, prev;" alternative) |
|||
Line 289: | Line 289: | ||
</html></lang> |
</html></lang> |
||
No output<br> |
No output<br> |
||
Manually moving the declaration of prev to before the loop, or changing the third "let" to "var" (causes legacy hoisting and) gives: |
Manually moving the declaration of prev to before the loop, or using <code>for (let i=0, prev; i<7; i+=1)</code>, or changing the third "let" to "var" (causes legacy hoisting and) gives: |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |