What Are Whitespace and Line Breaks in JavaScript?

JavascriptWeb DevelopmentFront End Technology

JavaScript ignores spaces, tabs, and newlines that appear in JavaScript programs. You can use spaces, tabs, and newlines freely in your program and you are free to format and indent your programs in a neat and consistent way that makes the code easy to read and understand.

JavaScript ignores whitespaces. For example, the following are same:

var employee = "Amit";
var employee="Amit";

Line breaks in JavaScript:

<!DOCTYPE html>
      <p>Line-break in an alert box. Click below button.</p>
      <button onclick="alert('Hi\nWelcome to Tutorialspoint')">Click</button>
Published on 22-Jan-2018 09:09:36