![]() |
VOOZH | about |
The nullish coalescing (??) operator is used to handle null and undefined values in JavaScript. It allows you to assign a default value when a variable does not have a valid value.
Example 1: In this example, we will see a basic function using the nullish coalescing operator
Syntax:
variable ?? default_valueExample 2: The more common use case is to set default values for JSON objects as follows.