本文介绍了Javascript中字符串中$ {}(美元符号和花括号)的含义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在这里或在MDN上没有看到任何东西。我确定我只是遗漏了一些东西。这个地方必须有一些文档吗?
I haven't seen anything here or on MDN. I'm sure I'm just missing something. There's got to be some documentation on this somewhere?
从功能上看,它看起来像是允许你在一个字符串中嵌套一个变量,而不使用 + 运算符。我正在寻找有关此功能的文档。
Functionally, it looks like it allows you to nest a variable inside a string without doing concatenation using the +
operator. I'm looking for documentation on this feature.
示例:
var string = 'this is a string';
console.log('Insert a string here: ${string}');
推荐答案
你在谈论。
它们允许多行字符串和字符串插值。
They allow for both multiline strings and string interpolation.
多行字符串:
console.log(`foo
bar`);
// foo
// bar
字符串插值:
var foo = 'bar';
console.log(`Let's meet at the ${foo}`);
// Let's meet at the bar
这篇关于Javascript中字符串中$ {}(美元符号和花括号)的含义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!