Leo Liu's blog

Archives · 2022

Home

About

Archives

Javascript

Var, Let - What's Difference In The For Loop

We’ve all written simple for loops to iterate over arrays and objects countless times. But have you ever stopped to consider how the scope of variables used inside loops works? I recently came across an interesting code snippet that highlighted an important distinction between var and let in this context. for (var i = 0; i < 3; i++) { const log =..

Read more