← Quiz: Error Handling and Debugging: all 10 questions
Quiz: Error Handling and Debugging · Question 5 of 10
Why throw new Error("…") instead of throw "failed"?
Why throw new Error("…") instead of throw "failed"?
- A.Strings cannot be thrown
- B.Error objects carry a name and a stack trace that show where the problem happened
- C.It is faster
- D.Strings are caught twice
Answer & explanation
Correct answer: Error objects carry a name and a stack trace that show where the problem happened
Without the stack, finding the source of a thrown string is much harder.
Can you get the rest right without peeking?
Take the timed Quiz: Error Handling and Debugging quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →