Use "+" to concatenate strings
console.log("Name is "+name+"")
but not the template literal
console.log(`name is ${name})`)
Are the benefits of using only improved visibility?
Whenever I do string concatenation, I always wonder which one to use.
javascript ecmascript-6
I think it's good to use the template literal only to improve visibility.
ESLint's fix option also provides automatic conversion.
https://eslint.org/docs/rules/prefer-template
One advantage is that "
or '
appear in the string, but no escape is required.On the other hand, `
needs to be escaped, but it's not something I use that much.
© 2024 OneMinuteCode. All rights reserved.