Skip to content

Instantly share code, notes, and snippets.

@gladchinda
Created April 18, 2018 08:55
Show Gist options
  • Save gladchinda/b9007b30424ced816421c9ac3caae2a0 to your computer and use it in GitHub Desktop.
Save gladchinda/b9007b30424ced816421c9ac3caae2a0 to your computer and use it in GitHub Desktop.
const student = {
name: 'John Doe',
age: 16,
scores: {
maths: 74,
english: 63
}
};
// We define 3 local variables: name, maths, science
const { name, scores: {maths, science = 50} } = student;
console.log(`${name} scored ${maths} in Maths and ${science} in Elementary Science.`);
// John Doe scored 74 in Maths and 50 in Elementary Science.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment