Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

JavaScript Destructuring - From ES6

// assigning object attributes to variables
const person = {
    name: 'Sara',
    age: 25,
    gender: 'female'    
}

// destructuring assignment
let { name, age, gender } = person;

console.log(name); // Sara
console.log(age); // 25
console.log(gender); // female
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #JavaScript #Destructuring #From
ADD COMMENT
Topic
Name
7+8 =