DEV Community

Discussion on: JS: Why we should also use formatted strings

Collapse
 
valeriavg profile image
Valeria • Edited

We shouldn't always use template literals. For example, in cases where newlines matter it's better to concatenate strings differently:

const yamlConfig=`var1: 1
var2: 2
var3: "something else"`
// Versus:
const yamlConfig=
     'var1: 1\r\n'+
     'var2: 2\r\n'+
     'var3: "something else"'
Enter fullscreen mode Exit fullscreen mode