MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/xhdyoe/new_strings_method_in_es6_javascript/ioxash4/?context=3
r/javascript • u/__Disaster497 • Sep 18 '22
17 comments sorted by
View all comments
8
Why use
`${name}`.method()
Instead of just
name.method()
6 u/xroalx Sep 18 '22 Well, using template literal will convert name to string if it isn't already, which might be useful in certain cases, but if we know it's a string already there's really no point at all. 2 u/senocular Sep 19 '22 Unless it's a symbol. String(name) would be safer. 1 u/__Disaster497 Sep 22 '22 Thanks for the suggestion, I will keep in mind next time 😁🤝
6
Well, using template literal will convert name to string if it isn't already, which might be useful in certain cases, but if we know it's a string already there's really no point at all.
name
2 u/senocular Sep 19 '22 Unless it's a symbol. String(name) would be safer.
2
Unless it's a symbol. String(name) would be safer.
String(name)
1
Thanks for the suggestion, I will keep in mind next time 😁🤝
8
u/yo-chill Sep 18 '22
Why use
Instead of just