js中的${}作用

js中的${}作用

作为ES6中新增的字符串方法,其作用是配合反单引号实现字符串拼接。代替以前传统复杂的引号双引号与+的拼接,简介明了,非常好用。

反单引号:键盘左上角esc下方的按键

用法示例:

let a='test';

let str=`This is a ${
      
      a}`;

console.log(str);

//输出: This is a test

猜你喜欢

转载自blog.csdn.net/m0_46893049/article/details/126464275