- Esecutori
-
Impara
Impara Python Esempi eseguibili, NumPy, pandas e altro Impara l'IA / Machine LearningReti neurali, ML e LLM da zero Impara C e C++ Puntatori, memoria, STL e C++ moderno Impara C#Fondamenti, OOP, LINQ, async ed esercizi .NET Impara MatplotlibGrafici a linee, barre, dispersione e torta con visualizzatori Impara RustOwnership, trait, gestione degli errori e thread Impara GoSlice, interfacce, goroutine e canali Algoritmi Python Ricerca, ordinamento, ricorsione e visualizzazioni O(n) Algoritmi C e C++ Confronta le implementazioni in C e C++ Programmazione per bambini Impara a programmare giocando!
- QuizNuovo
- SfideNuovo
- Per docentiNuovo
- Aggiornamenti
- Offrimi un caffè
Quiz di JavaScript: Async Error Handling
Errors in asynchronous JavaScript don't always go where you expect. This quiz tests try/catch with await, .catch() and rethrowing, finally, why return await matters and what Node does with an unhandled rejection.
Domanda di esempio
Domanda 1 di 10What does this print?
const out = [];
async function fail() {
throw new Error("nope");
}
async function main() {
let p;
try {
p = fail();
out.push("try done");
} catch (e) {
out.push("caught");
}
await p.catch(e => out.push("later " + e.message));
console.log(out.join(", "));
}
main();
Mostra la risposta
D. try done, later nope Calling fail() without await doesn't throw; it returns a rejected promise. The try block finishes normally, and the error only shows up when the promise is handled with .catch().
Cosa copre questo quiz
try/catchonly catches what youawait- Rethrowing and recovering in
.catch() finallyin async codereturnvsreturn awaitinsidetry- Unhandled rejections and errors in timer callbacks
Domande frequenti
Serve un account?
No. Chiunque può giocare. Accedi per salvare XP, serie, badge e cronologia.
Posso rifarlo?
Sì. Il tuo miglior punteggio resta salvato, e domande e risposte vengono mescolate ogni volta.