Pergunta de entrevista da empresa Infrrd

output of setTimeOut inside for loop.

Respostas da entrevista

Sigiloso

14 de abr. de 2019

I told him it will return 0-9 if we use let instead of var. He was not convinced since he was expecting IIFE. Since he knew only that

Sigiloso

14 de ago. de 2020

I guess the question was 'How do I add a delay in a JavaScript loop?'. for (let i = 0; i < 5; i++) { (function(j) { setTimeout[function() { console.log(1000 * j ); }, 1000 * j); })(i); };