JS MASTER CLASS /// LEARN SYNTAX /// WRITE STATEMENTS /// AVOID ERRORS /// JS MASTER CLASS /// LEARN SYNTAX /// WRITE STATEMENTS /// AVOID ERRORS ///

JavaScript Basic Syntax

Learn the grammatical rules of the web. Structure your instructions with proper statements, identifiers, and casing.

syntax.js
1 / 12
12345
{ ; }

Tutor:JavaScript syntax is the set of rules that defines how JavaScript programs are constructed. Just like English has grammar, JS has syntax. Let's start with Statements.


Skill Matrix

UNLOCK NODES BY LEARNING CORE SYNTAX.

Concept: Statements

A JavaScript program consists of statements. A statement is an instruction executed by the browser. Always end them with a semicolon ;.

System Check

What punctuation mark should you use to end a JS statement?


Community Code-Net

Share Your Scripts

ACTIVE

Got stuck on a syntax error? Join the community to debug together and share clean code snippets.

JavaScript Core Syntax

Author

Pascual Vila

Frontend Instructor // Code Syllabus

A JavaScript program is a list of programming instructions. In programming, these instructions are called statements. Understanding the fundamental syntax is the first step to mastering the language.

Statements & Semicolons

Statements are separated by semicolons (;). While JavaScript has a mechanism called Automatic Semicolon Insertion (ASI) that will try to fix missing semicolons by adding them at line breaks, relying on it is considered a bad practice.

let x, y, z; // Statement 1
x = 5; // Statement 2
y = 6; // Statement 3
z = x + y; // Statement 4

Case Sensitivity

All JavaScript identifiers are case-sensitive. The variables lastName and lastname are two completely different variables. Furthermore, keywords must be written in lowercase (e.g., let, not LET or Let).

Identifiers (Naming Rules)

Identifiers are names. In JavaScript, identifiers are used to name variables, keywords, and functions. The rules for legal names are strictly enforced:

  • A name must begin with a letter (A-Z or a-z), a dollar sign ($), or an underscore (_).
  • Subsequent characters may be letters, digits (0-9), underscores, or dollar signs.
  • Numbers are not allowed as the first character. This way JS can easily distinguish identifiers from numbers.
View Full Transcript+

This section contains the full detailed transcript covering whitespace ignoring, camelCase conventions commonly used by JavaScript developers, and the strict difference between syntax errors and runtime errors.

Syntax Glossary

Statement

A single instruction that tells the computer to perform an action. Separated by semicolons.

snippet.js

ASI

Automatic Semicolon Insertion. A JS engine feature that inserts missing semicolons at line breaks.

snippet.js

Identifier

A name given to a variable, function, or property. Cannot start with a number.

snippet.js

Case-Sensitive

Treating uppercase and lowercase letters differently. 'Var' and 'var' are not the same.

snippet.js

Whitespace

Spaces, tabs, and newlines. JS ignores extra whitespace, allowing for code formatting.

snippet.js

Keyword

Reserved words that have special meaning in JavaScript and cannot be used as identifiers.

snippet.js