Which statement accurately describes the difference between null and undefined in JavaScript?

Prepare for the TJR Bootcamp Test with quizzes and flashcards. Each question includes hints and explanations to boost your readiness for the exam!

Multiple Choice

Which statement accurately describes the difference between null and undefined in JavaScript?

Undefined describes a value that hasn’t been assigned yet. When you declare a variable without giving it a value, its value is undefined. It also shows up when a function parameter isn’t provided or when you access an array element that doesn’t exist. Null, by contrast, is an explicit value you assign to indicate “no value right now”—you’re intentionally saying this variable should be empty.

A notable quirk is that typeof null yields 'object' in JavaScript, a historical quirk rather than a true type indication. Because of that, to check for the absence of a value you’d compare with null (for example, value === null) or use a broader falsy check if appropriate.

So, the statement that correctly captures the distinction is that undefined means a variable has been declared but has no value yet, while null is an explicit value indicating no value.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy