Skip to content

Instantly share code, notes, and snippets.

@nonseodion
Last active March 13, 2020 13:03
Show Gist options
  • Save nonseodion/192c7acdbf40183728d0623a88fd70a1 to your computer and use it in GitHub Desktop.
Save nonseodion/192c7acdbf40183728d0623a88fd70a1 to your computer and use it in GitHub Desktop.
Damian = {age: 4,
hobby: "reading",
scores:{maths: 83,
english: 79,
writing: 44
}
}
//it looks very similar to the basic destructuring syntax
//however you should note the nested object names are not assigned
//a value only the property names.
let {hobby, scores:{maths, english}} = Damian;
console.log("Damian loves "+hobby +" he had " + maths +
" in Math and " + english + " in English.");
//Damian loves reading he had 83 in Math and 79 in English.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment