Last active
March 31, 2016 20:58
-
-
Save cmoody/2ad8c068c1654ba7ccd1c7a874313217 to your computer and use it in GitHub Desktop.
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
// 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