In Javascript it is possible to deconstruct objects and supply default values to declare variables. Below the name property of school object inside user object would be assigned to the name variable. However this also happens for undefined variables.
const user = {
id: 339,
name: 'Fred',
age: 42,
education: {
school: {
name: undefined
}
}
}
const {education: {school: {name}} = {school: {name: 'Dunno'}}} = user;
console.log(name); //prints: undefined
Above example is from Destructuring Nested Objects
Is there a way to guard against that inside the deconstruction so that name would print the default 'Dunno'?