
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
What Are Whitespace and Line Breaks in JavaScript?
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> <html> <body> <p>Line-break in an alert box. Click below button.</p> <button onclick="alert('Hi
Welcome to Tutorialspoint')">Click</button> </body> </html>
- Related Articles
- How to handle tabs, line breaks and whitespace in a text in JavaScript?
- How to Line Breaks to JavaScript Alert?
- How to replace line breaks with using JavaScript?
- How to replace line breaks in a string in C#?
- HTML5 canvas ctx.fillText won't do line breaks
- How to add line breaks to an HTML textarea?
- Replacing zero starting with whitespace in JavaScript
- Converting whitespace string to url in JavaScript
- What is the difference between single-line and multi-line comments in JavaScript?
- Replace whitespace in different elements with the same class in JavaScript?
- Whitespace in C++
- What are MAX_VALUE and MIN_VALUE in JavaScript?
- What is Line and Line segment ?
- What are decorators and how are they used in JavaScript?
- Remove whitespace in Java string.

Advertisements