在JavaScript中使用回勾字符(`)?在JavaScript中,反勾†就像一句单引号一样。例如,我可以使用回勾来定义如下字符串:var s = `abc`;反勾的行为与单引号的行为有什么不同之处吗?†注意,在程序员中,“回勾”是更一般称为严肃口音..程序员有时也会使用备选名称“回溯”和“回溯”。还有,论堆栈溢出在其他地方,“反勾”的其他常见拼写是“反滴答”和“反滴答”。
3 回答
猛跑小猪
TA贡献1858条经验 获得超8个赞
`
特征:
我们可以在模板文字中插值任何一种表达式。 他们可以是多行的。
注:'
"
`
).
例子:
var nameStr = `I'm "Rohit" Jindal`;
${expression}
var name = 'Rohit Jindal';var text = `My name is ${name}`;console.log(text); // My name is Rohit Jindal
\n
例子:
const name = 'Rohit';console.log(`Hello ${name}! How are you?`);
产出:
Hello Rohit! How are you?
添加回答
举报
0/150
提交
取消