#Shorts
👉For each loop, the setTimeout must create an execution context for the method setTimeout(). As loop iterated 5 times, so there are 5 execution context created ( each with one setTimeout() ). So once loop ended, the value for i = 5 ( as last statement is i++ ). The execution state for the for loop popped out now.
👉Now for each setTimeout() ( pushed 5 times in the execution context ), invoked after 1 second with a console.log(i). What's the value for i now? i is global here so, value will be 5.
#javascript
#javascripttutorial
#javascriptforbeginners
#javascripttips
#javascripttricks
#javascriptloop
#loop
#setTimeout
----------
🎶
When you are using this track, please put this in your description:
Track: A Himitsu - Adventures [NCS Fanmade]
Music provided by Audio Library • Adventures – A Himitsu (No Copyright Music)
Music released by Argofox • A Himitsu - Adventures [Royalty Free Music]
Download / Stream: https://goo.gl/zzsgxy
Link to this video: • A Himitsu - Adventures [NCS Fanmade] (optional)
Nesta página do site você pode assistir ao vídeo on-line setTimeout( ) inside a loop - JavaScript Tutorial duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário stepUP 25 Julho 2021, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 498 vezes e gostou 7 espectadores. Boa visualização!