【发布时间】:2018-11-16 23:31:27
【问题描述】:
如果我在浏览器控制台中输入这个表达式(带有重音):
Math.sin`1`
它会返回:
0.8414709848078965
但是如果我输入这个表达式(单引号):
Math.sin'1'
它会返回错误:
SyntaxError: Unexpected number
你能解释一下为什么会这样吗?
【问题讨论】:
-
tag`template literal`︁是 specifically part of the template literal syntax。它不适用于其他字符串文字。 -
谢谢!我的手册中的模板字符串部分没有指向标签的链接。
标签: javascript syntax tags