Line terminator (Definition)

Line terminators separate individual lines of executable code.


ECMAScript edition - 2

Line terminators are used to improve the readability of the source text and to separate tokens. However, unlike whitespace, line terminators can affect the behavior of the script when placed in certain places.

In general, a line terminator can occur between any two tokens but cannot appear in a token or inside a string literal. Line terminators in string literals must be escaped if they are required as part of the string. Line terminators also affect the automatic semicolon insertion process.

Line terminators occurring during a single line comment delimited by a pair of slash characters (//) are considered to be the end of the comment, and any remaining comment text be interpreted as if it were executable code.

Line terminators occurring during a multiple line comment block (/* ... */) will be discarded and the entire comment block will be replaced with a single line terminator.

The following characters are considered to be line terminators in ECMAScript conformant JavaScript interpreters:

Escape SequenceUnicode ValueNameSymbol
\n\u000ALine Feed<LF>
\r\u000DCarriage Return<CR>
-\2028Line separator<LS>
-\2029Paragraph separator<PS>

The terms Line Terminator and Newline can for most purposes be used interchangeably. Newline is preferred when referring to a \n escape sequence since it more clearly suggests the meaning of the escape.

ECMA edition 3 adds the Unicode line separator and paragraph separator code points to the list of valid line terminators.

See also:Automatic semicolon insertion, Comment (// and /* ... */), Lexical convention, Lexical element, Line, Newline, Semicolon (;), String literal


ECMA 262 edition 2 - section - 7.2

ECMA 262 edition 2 - section - 7.8

ECMA 262 edition 3 - section - 7.3