Variable declaration reset: Difference between revisions
Content added Content deleted
(→{{header|JavaScript}}: added "for(i=0, prev;" alternative) |
m (→{{header|JavaScript}}: init remark, added "Any of 1) / 2) / 3)") |
||
Line 289: | Line 289: | ||
</html></lang> |
</html></lang> |
||
No output<br> |
No output<br> |
||
Any of 1) manually moving the declaration of prev to before the loop, or 2) using <code>for (let i=0, prev; i<7; i+=1)</code>, and in fact initialising prev there, to any value, works exactly the same, or 3) changing the third "let" to "var" (causes legacy hoisting and) gives: |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre> |