javascript - 哪些浏览器支持多行字符串?

标签 javascript string cross-browser

哪些浏览器支持multi-line strings

"foo \
bar"

像往常一样,我主要怀疑不支持它的是 IE。 哪个 IE 版本最先支持它?

最佳答案

所有主流浏览器的当前版本都接受多行字符串。

Note: this technique is apparently not in compliance with browser standards; however, it works out fine when tested across all current versions of the major browsers.

  • 一些在线工具如 JSLint 不允许这样做
  • 多行字符串在 JavaScript 中可能很危险,因为如果您不小心在转义字符 (\) 和新行之间放置了一个空格,一切都会变得一团糟。 (@ripper234 评论)

多行字符串文字是 disallowed by the Google Style Guide .

关于javascript - 哪些浏览器支持多行字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13808042/

相关文章:

javascript - 搜索日期是否包含列表中的月份

Javascript - 替换 '%20' 空格

Java解析带有大量空格的字符串

c - 向用户读入字符串,直到使用 "."

html - 位置 : fixed Background DIV with images makes scrolling slow: How to make conditional CSS rules for browser-compatibility?

javascript - Node.js:启动 pg.Pool()

javascript - javascript 如何用交互的东西替换 html 输入的基本概念?

java - Java中的compareTo()函数

javascript - 尝试从客户端的 Medium API 访问公共(public)故事时出错

javascript - iframe.src 属性中的 "javascript:"、 "#"和 "javascript:false"有什么区别