JavaScript · Middle · Question 58 of 75
Which error does undefinedVariable.foo throw, and which null.foo?
- ✓Correct answer:
ReferenceError(variable not declared) andTypeError(reading a property of null) - 2
TypeErrorin both cases - 3
SyntaxErrorandTypeError
Explanation
ReferenceError means a name can't be resolved; TypeError means a value is used in a way its type doesn't allow. Checking err instanceof TypeError helps handle errors precisely.