我需要从这个对象中解构并获取 title、child、childTitle 的值
const obj1 = {
title : 'foo',
child : {
title2 : 'bar'
}
}
let {title, child} = obj1;
console.log(title) //'foo'
console.log(child) //{ title : 'bar' }
// but couldn't get child object this way
let { title , child : { title2 } } = obj1;
console.log(title) //'foo'
console.log(child) //unDefined
console.log(title2) //'bar'
我怎么能得到子对象?