Skip to content

Instantly share code, notes, and snippets.

@rishisidhu
Last active July 10, 2020 11:39
Show Gist options
  • Save rishisidhu/8c8fb23de87989d8809e20a01e8cd7e4 to your computer and use it in GitHub Desktop.
Save rishisidhu/8c8fb23de87989d8809e20a01e8cd7e4 to your computer and use it in GitHub Desktop.
Modern JS ES6+ features - Destructuring Objects
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