Learn JavaScript
Object Destructuring
35.5
Lesson

Set Default Values

We can store default values for the properties using =. The default values are used only if the value is missing in the object.

In the example given below, we store the default value 20 to the age variable. Since the age property is missing in the person object, the default value is used.