The JavaScript Language Syntax

JavaScript·6 min read·Jan 27, 2026

In JavaScript, a program is a sequence of instructions that reads values, transforms them, and eventually produces output.

Just like any other programming language, JavaScript has its own syntactic rules, which determine how these instructions are interpreted and executed by the Node.js runtime environment.

Statements and execution order

In JavaScript, instructions called statements are composed of keywords, values, operators, expressions, and comments.

They include all the available JavaScript and Node.js builtins functions, but also additional structures, such as variables, conditions, and loops, that allow developers to create more complex logic and behavior by altering the standard execution flow of the script.

Within a script, statements are executed from top to bottom, one by one, in their order of declaration.

statement_1;
statement_2;
...

Each statement is terminated by a semicolon character (;), which allows for multiple statements to occur on a single line or a single statement to span on multiple lines:

let a = 1;

let b = 3;   let c = 4;

let d
= 5;

💡 Tip: As a rule of thumb, you should only declare one statement per line to improve the readability of your code.

Case sensitivity

JavaScript is a case-sensitive language, which means that it distinguishes between uppercase and lowercase letters.

This applies to variable names, function names, object properties, and other identifiers.

For example:

  • The variables name and Name are considered as different expressions.
  • Reserved keywords such as const, while, for, and so on must be written in lowercase.

Whitespaces and indentation

In JavaScript, whitespaces, including spaces and tabs, can be used to separate and format elements in the script.

While proper indentation and spacing improve code readability — especially within control structures and functions — they do not influence whatsoever the way the statements are interpreted and executed.

For example, these statements:

let x = 5;
let y = 6;

console.log(x + y);

Will be interpreted and executed they same way as these ones:

let x = 5;    let y=6;
  console.log(x+ y);

📚 In programming, indentation refers to the use of leading spaces or tabs at the beginning of a line of code to visually indicate the structure of the program. This is particularly useful for establishing a visual hierarchy for statements that belong to the same code block (or group). This is mostly used in conditional statements, loops, and functions.

Comments

In JavaScript, comments are lines of text that are ignored by the interpreter, and therefore never executed.

They are mostly used to provide explanations, documentation, or notes that improve the script readability and make it easier for other developers (or your future self) to understand what it does.

Comments are also handy to temporarily disable part of your code without deleting it, for example, to isolate an issue while debugging faulty code logic and test alternative behavior quickly.

Single-line comments

Single-line comments start with the // characters and continue until the end of the line.

// This is a comment

let username = "john"; // This is a comment

// let password = "HelloWorld"

Multi-line comments

Multi-line comments start with a /* and end with a */, and everything in between is treated as a comment, regardless of line breaks.

/* This is a comment */

let username = "john";

/*
    This is a comment
*/

/*let email = "user@mail.com"
let age = 35;*/

🗒️ Summary

Here's a summary of what you've learned in this lesson:

  • JavaScript is a case sensitive language.
  • JavaScript ignores additional spaces and tabs.
  • JavaScript instructions are called statements.
  • Statements are read and executed in their order of declaration.
  • Statements are terminated by a semicolon character (;).
  • Single-line comments are declared using the // expression.
  • Multi-line comments are declared using the /**/ expression.