Created
August 12, 2021 01:44
-
-
Save sorie/f56458c6a19ac935095b9d444ab5cb60 to your computer and use it in GitHub Desktop.
javascript tip : template-literals.
This file contains hidden or 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
//Template Literals (Template String) | |
const person = { | |
name: 'Julia', | |
score: 4, | |
}; | |
//bad code | |
console.log( | |
'Hello ' + person.name + ', Your current score is: ' + person.score | |
); | |
//good code | |
console.log(`Hello ${person.name}, Your current score is: ${person.score}`); | |
//good code | |
const { name, score } = person; | |
console.log(`Hello ${name}, Your current score is : ${score}`); | |
//good code : 확장성을 위해 function안에 둔다. | |
function gretings(person) { | |
const { name, score } = person; | |
console.log(`Hello ${name}, Your current score is : ${score}`); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment