No. forEach does not await the async callback. The loop finishes immediately, and the async callbacks run in parallel in the background. This is usually not what you want. Use for...of for sequential await or Promise.all with map for parallel.
Does forEach await the async callback in JavaScript?
More FAQs in async/await in Loops in JavaScript
Use for...of: for (const url of urls) { const data = await fetch(url); process(data); }. Each iteration waits for the previous one. Use this for dependent operations.
Use Promise.all with map: const results = await Promise.all(urls.map(url => fetch(url))). All fetches start at once. Use this for independent operations (much faster than sequential).
Batch with Promise.all: process limit items at a time. for (let i = 0; i < items.length; i += limit) { await Promise.all(items.slice(i, i + limit).map(fn)); }. This avoids overwhelming the server.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.