Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of ES6 Object Destructuring Assignment - Deeply Nested Objects
/* ES5 */
var catMaru = {
name: 'Maru',
appearance: {
mittens: true,
coat: 'tabby'
}
};
var name = catMaru.name;
var color = catMaru.appearance.coat;
/* >= ES6 */
var catMaru = {
name: 'Maru',
appearance: {
mittens: true,
coat: 'tabby'
}
};
var { name, appearance: { coat } } = catMaru;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment