Skip to content

Instantly share code, notes, and snippets.

@cmoody
Last active March 31, 2016 20:58
Show Gist options
  • Save cmoody/2ad8c068c1654ba7ccd1c7a874313217 to your computer and use it in GitHub Desktop.
Save cmoody/2ad8c068c1654ba7ccd1c7a874313217 to your computer and use it in GitHub Desktop.
// Received from API call
const data = {
Place: {
Name: 'Veracruz Tacos',
Address: '1704 E Cesar Chavez Austin, TX 78702',
Phone: '512.981.1760'
}
};
// Without destructuring
function withoutDestructuring(data) {
console.log(data.Place.Name);
console.log(data.Place.Address);
console.log(data.Place.Phone);
}
// With destructuring
function withDestructuring(data) {
let { Name, Address, Phone } = data.Place;
console.log(Name);
console.log(Address);
console.log(Phone);
}
withoutDestructuring(data);
withDestructuring(data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment