JavaScript Core Syntax
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 4Case 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.
