Stephen
1 min readJun 4, 2018

--

Thanks, I enjoyed writing it.

I love template literals but there are some times when I think they are no more clear, or possibly less clear, than string concatenation. I don’t consider it a best practice to always require template literals. I think there’s a variety of cases where concatenation is just as clear or even more clear. Specifically, one liners where the variable is at the beginning or end of the line, I think requiring all strings with variables to use template literals is not necessarily preferable. E.g.:

const newMessageCount = 6;
const newMessageString = "New Message Count: " + newMessageCount;

as compared to

const newMessageCount = 6;
const newMessageString = `New Message Count: ${newMessageCount}`;

This post on HashNode had some good examples of cases when devs wouldn’t want template literals to be required. https://hashnode.com/post/es6-template-literals-vs-es5-string-concatenation-cissud2fd01gvtg53iv2x80x7

Thanks for reading.

--

--

No responses yet