for/while iterator closure?
JavaScript
function testWhile()
{
let i = 0;
while(i < 5)
{
setTimeout(() =>
{
console.log(`While: ${i}`);
}, 0)
i++
}
}
function testFor()
{
for(let i = 0; i < 5; i++)
{
setTimeout(() =>
{
console.log(`For: ${i}`);
}, 0)
}
}
testWhile();
testFor();