As a developer, we need to be able to adapt and understand whatever environment we're thrown in.
#Javascript clean text code#
Why? Because not every code base will follow this rule or you might be dealing with a legacy code base.
It's still important to know the other ways as well. So template strings for the win! ? # Why the other ways still matter? eslint: prefer-template template-curly-spacing When programmatically building up strings, use template strings instead of concatenation. Thats exactly what template strings is trying to. When it comes to stylistic preference, I like to follow Airbnb Style guide. If you come from another language, such as Ruby, you will be familiar with the term string interpolation. Which way is better all depends on the situation. I showed a few examples of using the different ways of concatenating strings. The general strategy for replacing a pattern. Const flag = '??' ` Use backtick \`\` to create a template string ` // RESULT // Use backtick `` to create a template stringīecause the other string creations are not using backtick, this scenario doesn't apply to them ? # Which way to use? There is no JavaScript native method replaceAll(), which replaces all instances of a character with a replacement.