18_destruct_2.js 233 B

12345678910111213
  1. let obj = {
  2. name: 'Ivan',
  3. surname: 'Petrov',
  4. children: [
  5. {name: 'Maria'},
  6. {name: 'Nikolay'}
  7. ]
  8. }
  9. const {children: [{name: name1}, {name: name2}]} = obj;
  10. console.log(name1) // Maria;
  11. console.log(name2) // Nikolay;