JavaScript · Middle · Question 58 of 75

Which error does undefinedVariable.foo throw, and which null.foo?

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.

Further reading

Problem with a question

JavaScript · Middle · question 58

Test yourself

Take the JavaScript · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz