Skip to content
Advertisement

Unpacking fields from nested objects passed as a parameter

How can I unpack nested object passed as a parameter? I want to unpack age from the object how can I do that?

JavaScript

Advertisement

Answer

You can destructure any level as:

JavaScript

or, if you don’t want to assign to a new variable name then:

JavaScript

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement