Last active
July 10, 2020 11:39
-
-
Save rishisidhu/8c8fb23de87989d8809e20a01e8cd7e4 to your computer and use it in GitHub Desktop.
Modern JS ES6+ features - Destructuring Objects
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 financialInfo = { | |
City: "New York", | |
Artform: "Jazz", | |
Artist: "Miles Davis", | |
TicketCurrency: "$", | |
Cost: 200, | |
}; | |
//Destructuring Object | |
const { Artist, TicketCurrency, Cost } = financialInfo; | |
console.log(`For ${Artist} please pay ${Cost}${TicketCurrency}`); | |
//Object destructuring with alias creation | |
const { Artist: a, TicketCurrency: tc, Cost: c } = financialInfo; | |
console.log(`For ${a} please pay ${c}${tc}`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment