Created
August 12, 2021 00:57
-
-
Save sorie/53ba2219658ad20917550ae529f99a9d to your computer and use it in GitHub Desktop.
javascript tip : object destructuring
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
//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