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 title
property and the third age
in the array (via object destructuring)
I can do it via :
let { title:lectureTitle , topics:[,,{age:thirdAge}]} = lecture;
console.log(lectureTitle,thirdAge);//MyTitle 3
Question
But what if the array has 100 items and I want the 99'th age
?
How would then I do it ? Does object destructuring offer a solution for that?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…