21 lines
410 B
Plaintext
21 lines
410 B
Plaintext
ECMAScript 2015 added the ability to use template literals instead of concatenation. Since their use is clearer and more concise, they are preferred in environments that support ECMAScript 2015.
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
----
|
|
function sayHello(name) {
|
|
console.log("hello " + name); // Noncompliant
|
|
}
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
function sayHello(name) {
|
|
console.log(`hello ${name}`);
|
|
}
|
|
----
|
|
|