Skip to content

Instantly share code, notes, and snippets.

@gladchinda
Created April 18, 2018 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gladchinda/54211d5f58a88a46b02339a871710a03 to your computer and use it in GitHub Desktop.
Save gladchinda/54211d5f58a88a46b02339a871710a03 to your computer and use it in GitHub Desktop.
const person = {
name: 'John Doe',
country: 'Canada'
};
// Assign default value of 25 to years if age key is undefined
const { name: fullname, country: place, age: years = 25 } = person;
// Here I am using ES6 template literals
console.log(`I am ${fullname} from ${place} and I am ${years} years old.`);
// I am John Doe from Canada and I am 25 years old.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment