Is it best practice to use string concatenation or string interpolation? Why?


#1

Question

Is it best practice to use string concatenation or string interpolation? Why?

Answer

String interpolation was a new feature of ES6 - string interpolation, using template literals, allows us to include variables and expressions in our strings, we can make multi-line strings without the need for an escape character, we can use apostrophes and quotes easily, they can make our strings and therefore our code easier to read as well. These are some of the reasons to use string interpolation over string concatenation. Also, if we choose to use ES6+ syntax, string interpolation would be better practice to use, in most cases, for the sake of consistency in our code.