Basics: Semicolons, white space and sensitivity


Every statement in a JavaScript program is optionally terminated using semicolons.

I said optionally, because the JavaScript interpreter is smart enough to introduce semicolons for you.

In most cases, you can omit semicolons altogether from your programs.

This fact is very controversial, and you’ll always find code that uses semicolons and code that does not.

My personal preference is to always avoid semicolons unless strictly necessary.

White space

JavaScript does not consider white space meaningful. Spaces and line breaks can be added in any fashion you might like, even though this is in theory.

In practice, you will most likely keep a well defined style and adhere to what people commonly use.

For example, I like to always use 2 characters to indent.

Case sensitivity

JavaScript is case sensitive.

A variable named something is different from Something.

A variable named AGE is different from age and from ‘aGe’.

Lessons in this unit:

0: Introduction
1: Literals, identifiers and variables
2: Comments
3: The difference between let, const and var
4: Types
5: Operators and expressions
6: Let's start with arithmetic operators
7: The assignment operator
8: Operators precedence
9: Strings
10: Numbers
11: ▶︎ Semicolons, white space and sensitivity
Want to learn more? Check out our courses