Why does const work in some for-loops in JavaScript? : <p>I <strong>do know</strong> why <code>const</code> doesn't work in for-loops. We need to create a new scope and copy over a value into that. So this won't fly.</p>

<pre><code>for(const i = 0; i &lt; 5; i++) console.log(i);
</code></pre>

<p>Whereas this will.</p>

<pre><code>for(let i = 0; i &lt; 5; i++) console.log(i);
</code></pre>

<p>However, I noticed that both of them work when looping though the properties of an object like this.</p>

<pre><code>for(let property in thingy) console.log(property);
for(const property in thingy) console.log(property);
</code></pre>

<p>I'm not sure why.</p>
