Skip to content

Instantly share code, notes, and snippets.

@sorie
Created August 12, 2021 00:57
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 sorie/53ba2219658ad20917550ae529f99a9d to your computer and use it in GitHub Desktop.
Save sorie/53ba2219658ad20917550ae529f99a9d to your computer and use it in GitHub Desktop.
javascript tip : object destructuring
//Object Destructuring
const person = {
name = 'Julia',
age = 20,
phone: '0102222222'
};
//bad code
function displayPerson(person){
displayAvatar(person.name);
displayName(person.name);
displayProfile(person.name, person.age);
}
fucntion displayPerson(person) {
const { name, age } = person;
displayAvatar(name);
displayName(name);
displayProfile(name, age);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment