18 lines
594 B
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
Template strings allow developers to embed variables or expressions in strings using template literals, instead of string concatenation. This is done by using expressions like ``++${variable} ++`` in a string between two back-ticks (``++`++``). However, when used in a regular string literal (between double or single quotes) the template will not be evaluated and will be used as a literal, which is probably not what was intended.
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
----
console.log("Today is ${date}"); // Noncompliant
----
2021-04-28 16:49:39 +02:00
== Compliant Solution
----
console.log(`Today is ${date}`);
----