[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Errors/String_literal_EOL [Back]  [Original]

SyntaxError: string literal contains an unescaped line break - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

SyntaxError: string literal contains an unescaped line break

SyntaxError: Invalid or unexpected token (V8-based)
SyntaxError: '' string literal contains an unescaped line break (Firefox)
SyntaxError: Unexpected EOF (Safari)

SyntaxError

js Javascript

javascript

js
var longString = "This is a very long string which needs
                  to wrap across multiple lines because
                  otherwise my code is unreadable.";
// SyntaxError: unterminated string literal

"+"+

js
var longString =
  "This is a very long string which needs " +
  "to wrap across multiple lines because " +
  "otherwise my code is unreadable.";

\\\

js
var longString =
  "This is a very long string which needs \
to wrap across multiple lines because \
otherwise my code is unreadable.";

ES 2015 ` `

js
var longString = `This is a very long string which needs
                  to wrap across multiple lines because
                  otherwise my code is unreadable.`;


Web Proxy Viewer  |  New URL  |  Original Page