async-await.js
async function fetchUser(id) {
const name = await Promise.resolve("user-" + id);
return { id, name };
}
async function main() {
const users = [];
for (let id = 1; id <= 3; id++) {
const u = await fetchUser(id);
users.push(u);
}
const names = await Promise.all(users.map((u) => u.name));
return names;
}
main();
What to watch
Each await unwraps a Promise inline; the result object shows state + value, and the call stack walks through both async functions.
Reading async / awaiton a page only gets you so far - code is a process, and the process happens at runtime where you can't normally see it. In NeonFlow, this exact program runs step by step: every call opens a frame, every branch picks a path, and every value moves through memory in front of you. That's the fastest way to actually understand how async / await works.
Run async / await yourself
Open NeonFlow, paste this code (or any of your own), and scrub through it one step at a time.
Open NeonFlow