Created
April 18, 2018 09:31
-
-
Save gladchinda/4863a5784f0d9ecc2065caf9d17dcea8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 person = { | |
name: 'John Doe', | |
age: 25, | |
location: { | |
country: 'Canada', | |
city: 'Vancouver', | |
coordinates: [49.2827, -123.1207] | |
} | |
} | |
// Observe how mix of object and array destructuring is being used here | |
// We are assigning 5 variables: name, country, city, lat, lng | |
const {name, location: {country, city, coordinates: [lat, lng]}} = person; | |
console.log(`I am ${name} from ${city}, ${country}. Latitude(${lat}), Longitude(${lng})`); | |
// I am John Doe from Vancouver, Canada. Latitude(49.2827), Longitude(-123.1207) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment