JavaScript
Wat zijn callbacks, promises en async/await?
Dit zijn 3 manieren om asynchrone code te hanteren. Modern: async/await.
Callbacks (oud)
Functie als parameter. Probleem: callback hell met nested callbacks.
Promises (beter)
new Promise((resolve, reject) => {...}) Chain met .then().catch() Testen of rejected: .finally()
Async/Await (best)
async function maakt functie promise-based await wacht op promise resolution Try/catch voor error handling
Code Voorbeelden
JAVASCRIPTCallbacks vs Promises vs Async✏️ Interactief
✏️CODE AANPASSEN
LIVE PREVIEW
Relevante trefwoorden
asyncawaitpromisecallback