Last active
November 3, 2022 02:59
-
-
Save sveggiani/173a31d09a077e15c2d4c200114d146a to your computer and use it in GitHub Desktop.
[Double destructuring with rename] #javascript #masscode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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