Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which browsers support multi-line strings?

Which browsers support multi-line strings?

"foo \
bar"

As usual, my main suspect for not supporting it is IE. Which IE version is the first that supports it?

like image 941
ripper234 Avatar asked Dec 10 '12 19:12

ripper234


1 Answers

All current versions of the major browsers accept multi-line strings.

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.

  • Some online tools such as JSLint don't allow it
  • Multi-line strings can be dangerous in JavaScript because all hell breaks loose if you accidentally put a whitespace in between the escape character (\) and a new line. (@ripper234 comment)

Multiline String literals are disallowed by the Google Style Guide.

like image 68
KingKongFrog Avatar answered Oct 06 '22 21:10

KingKongFrog