Template literal is the syntax of writing a new way of the string enclosed in the backtick symbol. Template literals in ES6 support below features
- Interpolation
- Multi-Line String \
- tagged Templates
ES6 Template Literals Syntax
Template literals are a string with expressions, expressions are evaluated at runtime and replaced with the result.
String interpolation
const add = (first,second) => {
console.log(The addition of ${first} and ${second} is ${first + second}
);
}
module.exports = {sum}
how to create a multi-line string in javascript?
const multiLineString = `
multi-line string
`;if you use interpolation variable syntax