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:
Loading JavaScript Playground...
null
null is an intentional absence of value - you assign it explicitly:
Loading JavaScript Playground...
Checking for null/undefined
Loading JavaScript Playground...
Nullish Coalescing (??)
The ?? operator returns the right side if the left is null or undefined:
Loading JavaScript Playground...
Exercise: Default Values
Use nullish coalescing to provide a default value:
Loading JavaScript Exercise...
Exercise: Check Undefined
Check if a variable is undefined:
Loading JavaScript Exercise...

