Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

destructure nested object properties

const user = {
  name: 'Chris',
  age: 33,
  username: 'DailyDevTips',
  address: {
    country: 'South Africa',
    postalCode: '7700',
  },
};

const {
  address: { country },
} = user;

console.log(country);
// South Africa
Source by h.daily-dev-tips.com #
 
PREVIOUS NEXT
Tagged: #destructure #nested #object #properties
ADD COMMENT
Topic
Name
6+6 =