Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Destructuring object from a nested object

const person = {
    name: 'labib',
    age: 22,
    job: 'web-developer',
    frieds: ['ahsik', 'abir', 'alvi', 'hanafi'],
    childList: {
        firstChild: 'Salman',
        secondChild: 'Rafi',
        thirdChild: 'Anfi'
    }
}

//simple destructuring
const { name, age, job } = person;
console.log(name, age, job);
//Expected output: labib 22 web-developer
Source by h.daily-dev-tips.com #
 
PREVIOUS NEXT
Tagged: #Destructuring #object #nested #object
ADD COMMENT
Topic
Name
6+8 =