Looking at this code:
let lecture = {
id: 2,
title: "MyTitle",
topics: [
{
title: "John",
age: 1
},
{
title: "John2",
age: 2
},
{
title: "John3",
age: 3
}]
}
I want to extract the main property title
and the third age
in the array (through destructuring the object)
I can do it through :
let { title:lectureTitle , topics:[,,{age:thirdAge}]} = lecture;
console.log(lectureTitle,thirdAge);
Question
But what if the array has 100 elements and I want 99'th age
?
How would I do that? Is there a solution for object destruction for this?
source
share