Object Destructuring: Default and Parameter Values

Learn how to assign default values to object properties using object destructuring. In addition, understand the concept of extracting object properties when passed to a function as a parameter.

Assigning default values

When extracting object properties, if we ask for a property that is not present, we can assign a default value for the missing property.

Example

Here, we’re asking for a favorite property that is not present in the object it’s being extracted from. If the value is not present, the default value assigned to the property on the left-hand side kicks in.

Get hands-on with 1400+ tech skills courses.