let obj = {
name: 'Xiao Ming',
age: 18,
hobby: ['singing', 'dancing'],
game: { pvz: 'Senior Player' }
}
Assign Default Value When Destructuring Nonexistent Property#
// If ambition does not exist in obj, assign it the string "scientist"
let {ambition='scientist', name} = obj
console.log(ambition); // scientist
console.log(name); // Xiao Ming
Destructuring Property from Object's Object Property#
let {game: {pvz}} = obj
console.log(pvz); // Senior Player