DEV Community

loading...

Discussion on: Dealing with Promises In an Array with async/await

Collapse
4umfreak profile image
Mark Voorberg • Edited

I did not mean for-await-of, I mean:

  for (var i = 0; i < asyncFunctions.length; i++) {
    var result = await asyncFunctions[i]();
    console.log(result);
  }

Less code, less cognitive overhead!

jsfiddle.net/4umfreak/bkqcymuL/

Thread Thread
afifsohaili profile image
Afif Sohaili Author

Yeah, that's definitely a more readable approach. I have to be honest I haven't used for loops in a while so it didn't really occur to me.