DEV Community

Discussion on: Converting to Asynchronous Code Using IIFEs

Collapse
 
joaozitopolo profile image
Joao Polo

Sorry, but... You should to use promise.all in the first approach also, to can compare with the second approach:

//const num1 = await func1();
//const num2 = await func2();
//const num3 = await func3();
//const num4 = await func4();
Promise.all([func1(), func2(), func3(), func4()]).then(([num1, num2, num3, num4]) => ...)

and then, you'll have the same 4 seconds to run.

Awesome idea about small chunks with IIFE.