Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
// Bad: wrapping already-thenable in new Promise async function bad() { return new Promise(r => r(fetch("/api"))); } // Good: just return the fetch async function good() { return fetch("/api"); } // Bad: sequential awaits in loop (slow) for (const id of ids) { await processItem(id); } // Good: parallel await Promise.all(ids.map(processItem)); // Bad: swallow errors p.catch(() => {}); // silent failure!
Result
Open