EMCAScript 6 ( ES6 ) has introduce a new type of literal called
Template literals (Template strings) have many features like variable / expression interpolation, nesting templates, tagged templates etc. Template literals are delimited with backticks (
`), and allows embedded expressions called substitutions.
And among with these features, we also got the
Multi-line strings, any newline characters in the code or source is considered as a part of the template literal.
console.log('string text line 1\n' + 'string text line 2'); //OUTPUT // "string text line 1 // string text line 2"
In the above code, in order to create a new line we had to use
\n, it create a new line.
However, now using the
template literals, we can write multi-line like this example below:
console.log(`string text line 1 string text line 2`); //OUTPUT // "string text line 1 // string text line 2"
We just have to write the strings inside the backticks (
`) and it will be displayed as multiline.
This article is how to sort an array of string with non-ASCII characters. Using localeCompare() we can sort mixed array with non-ascii characters.