Created
April 18, 2018 08:41
-
-
Save gladchinda/4fc90ded5d51ed78069037259e64a9e3 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
// Initialize local variables | |
let country = 'Canada'; | |
let firstname = 'John'; | |
let lastname = 'Doe'; | |
const student = { | |
firstname: 'Glad', | |
lastname: 'Chinda', | |
country: 'Nigeria' | |
}; | |
// Reassign firstname and lastname using destructuring | |
// Enclose in a pair of parentheses, since this is an assignment expression | |
({ firstname, lastname } = student); | |
// country remains unchanged (Canada) | |
console.log(firstname, lastname, country); // Glad Chinda Canada |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment