首页 > 技术文章 > js中使用 反斜杠用来在文本字符串中插入省略号、换行符、引号和其他特殊字符。

sunny3158 2019-09-27 11:34 原文

代码输出
\' 单引号
\" 双引号
\& 和号
\\ 反斜杠
\n 换行符
\r 回车符
\t 制表符
\b 退格符
\f 换页符
var txt="We are the so-called \"Vikings\" from the north."
document.write(txt)

推荐阅读