Downlevel emit for let\const by vladima · Pull Request #2161 · microsoft/TypeScript (original) (raw)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest I don't think that there is any useful difference between the two. But there is a technical difference, as the loop body is a new scope nested inside the loop scope itself. It means that you can redeclare let i both in the loop initializer and the loop body. The initializer, loop increment and loop condition share one scope, the loop body is a nested scope.
Allen makes it very clear in his answer to this question: https://esdiscuss.org/topic/in-es6-do-for-loops-with-a-let-const-initializer-create-a-separate-scope