相关疑难解决方法(0)

如何在JavaScript中插入变量而没有连接?

我知道在PHP中我们可以这样做:

$hello = "foo";
$my_string = "I pity the $hello";
Run Code Online (Sandbox Code Playgroud)

输出: "I pity the foo"

我想知道在JavaScript中是否也可以使用同样的东西.在不使用串联的情况下在字符串中使用变量 - 它看起来更简洁和优雅.

javascript string variables string-interpolation

336
推荐指数
9
解决办法
50万
查看次数