JavaScript ES6 string formatting

The standard before JavaScript ES6 cannot format strings, and you can only use + if you want to concatenate strings

JavaScript ES6 supports the use of $ {variable name} to concatenate strings in strings, where they are automatically replaced. The specific use is as follows:

var name = 'ConstXiong';
var es5Str = 'I am ' + name;
var es6Str = `I am ${name}`;
console.log(es5Str);
console.log(es6Str);
//均输出 "I am ConstXiong"

 

 


[Java interview questions and answers] sorting recommendations

 

Published 562 original articles · praised 1543 · 1.65 million views +

Guess you like

Origin blog.csdn.net/meism5/article/details/105377132