Skip to content

Instantly share code, notes, and snippets.

@sveggiani
Last active November 3, 2022 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sveggiani/173a31d09a077e15c2d4c200114d146a to your computer and use it in GitHub Desktop.
Save sveggiani/173a31d09a077e15c2d4c200114d146a to your computer and use it in GitHub Desktop.
[Double destructuring with rename] #javascript #masscode
const source = {
data: {
bottomBanner: {
title: "The title",
link: {
text: "Link title",
url: "http://google.com/example"
}
}
}
};
// Here we are destructuring twice:
// 1. first get `data` from `source`,
// 2. then we get `bottomBanner` from `data`
// 3. then we get `link`from bottomBanner renamed to `newLinkName`
const {
data: { bottomBanner: { link: newLinkName } },
} = source;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment