How can a "for" loop be used for asynchronous operations efficiently?

  • By using "await" within the loop body
  • By using a "setTimeout" function inside the loop
  • By using "return" statements in the loop
  • By using "if...else" conditions in the loop
To use a "for" loop for asynchronous operations, you can use the "await" keyword within the loop body, making it an "async" function. This allows you to wait for asynchronous tasks to complete in each iteration, ensuring that the loop proceeds in an orderly fashion. The other options are not suitable for efficient asynchronous operations.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *