Line Breaks / Carriage Returns / Line Terminators

By: Dusty Arlia
Published on March 5, 2013
Last Updated on Sunday, July 12, 2015 at 12:25 AM
Total Updates: 4

Line breaks (or carriage returns) are a part of programming languages' syntax. Line breaks are not required for the program to work properly, but it helps the programmer visually. This type of spacing is included in what is known as whitespace (spaces, tabs, line breaks).

In the JavaScript programming language, line breaks or carriage returns are known as line terminators. JavaScript treats line breaks as semicolons when the next line cannot be interpreted as a continuation of the previous. There are two exceptions to this rule:

  1. JavaScript always treats line breaks after the return, break, and continue keywords as semicolons.
  2. JavaScript always treats line breaks before the -- and ++ postfix operators as semicolons. Always keep your operator right next to your variable like this: widgets_variable++