Skip to content

Instantly share code, notes, and snippets.

@jchiatt
Created October 26, 2018 23:48
Show Gist options
  • Save jchiatt/16e80bb13f5c941f8b603986bbd5bb04 to your computer and use it in GitHub Desktop.
Save jchiatt/16e80bb13f5c941f8b603986bbd5bb04 to your computer and use it in GitHub Desktop.
Final code for Destructuring Nested Objects in JavaScript Video
const benchPress = {
muscles: {
primary: "Chest",
secondary: "Triceps"
},
oneRepMax: {
variations: {
standard: {
lbs: 315,
kgs: 142.882
}
}
}
};
const {
muscles: { secondary }
} = benchPress;
console.log(secondary); // returns 'Triceps'
const {
oneRepMax: {
variations: {
standard: { lbs }
}
}
} = benchPress;
console.log(lbs); // returns 315
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment