Null and Undefined
JavaScript has two special values for "nothing": null and undefined. They're similar but have important differences.
undefined
A variable is undefined when declared but not assigned a value:
null
null is an intentional absence of value - you assign it explicitly:
Checking for null/undefined
Nullish Coalescing (??)
The ?? operator returns the right side if the left is null or undefined:
Exercise: Default Values
Use nullish coalescing to provide a default value:
Exercise: Check Undefined
Check if a variable is undefined:
Up next · Lesson 9 of 37
Type Coercion
1 min read
8 of 37 lessons done

Ask Byte about this lesson
A private chat about this lesson. Byte has read the whole lesson, answers in seconds, and shows the section each answer comes from. Ask follow-ups in any language.
Questions & Answers
Public questions about this lesson. The AI Tutor answers right away in your language, the FreeAcademy team checks answers, and every learner can read them.

