Welcome to the syntax documentation! This section covers the fundamental syntax elements and rules for writing valid code.
🧩 Basic Syntax Structure
Variables
- Use
let
orconst
to declare variables. - Example:
let name = "John";
- 📎 Learn more about variable declarations at /en/docs/
- Use
Control Structures
- If/else statements:
if (condition) { // code } else { // alternative code }
- Loops:
for
,while
,do-while
- 📎 Explore advanced control structures at /en/docs/advanced_topics
- If/else statements:
Functions
- Define functions with
function
keyword:function greet() { console.log("Hello!"); }
- Arrow functions:
const add = (a, b) => a + b;
- 📎 Check out function best practices at /en/docs/functions
- Define functions with
🧠 Tips for Clean Code
- Always use consistent indentation (e.g., 2 or 4 spaces).
- Avoid overly long lines; break them into multiple lines for readability.
- 📎 See our style guide at /en/docs/style
For visual learners, this diagram illustrates the basic syntax flow. Need further clarification? Dive deeper into our syntax tutorials.