"
还是'
?你的字符串里面在JavaScript中,你可以放置一个反斜杠 (从考虑到它作为字符串报价的最终逃脱报价\
在引号前)。 var sampleStr = "Alan said, \"Peter is learning JavaScript\".";
这告诉JavaScript,以下引用不是字符串的结尾,而是应该出现在字符串中。所以如果要将它打印到控制台,你会得到: Alan said, "Peter is learning JavaScript".
myStr
变量,这样如果要将其打印到控制台,您会看到: I am a "double quoted" string inside "double quotes".
"
)和四个转义双引号( \"
)。
testString: 'assert(code.match(/\\"/g).length === 4 && code.match(/[^\\]"/g).length === 2, "You should use two double quotes ("
) and four escaped double quotes (\"
).");'
- text: 变量myStr应该包含字符串: I am a "double quoted" string inside "double quotes".
testString: 'assert(myStr === "I am a \"double quoted\" string inside \"double quotes\".", "Variable myStr should contain the string: I am a "double quoted" string inside "double quotes".
");'
```