Question 5
Back to Exercise
The code below stops with an uncaught error. Which statement correctly describes the problem?
class QuotaError extends Error {
constructor(message) {
super(message);
this.name = "QuotaError";
}
}
throw QuotaError("Daily limit reached");
- A TypeError: class constructors cannot be invoked without new – write throw new QuotaError(…) Correct
- B It throws QuotaError: Daily limit reached
- C ReferenceError
- D It returns undefined
Correct Answer: Option A
Built-in Error("msg") works without new, which misleads people; classes never do.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!