JS Syntax
JavaScript syntax is the set of rules defining how JavaScript programs are written.
JavaScript syntax defines the rules for writing valid programs. The three core building blocks are literals (fixed values), variables (named storage), and expressions (computed values).
Try It — Syntax Building Blocks
Preview
Syntax Quick Reference
| Concept | Example |
|---|---|
| Number literal | 42, 3.14 |
| String literal | "Hello", 'World' |
| Boolean literal | true, false |
let variable | let name = "Alice"; |
const constant | const PI = 3.14; |
| Expression | width * height |
| Comment | // this is a comment |
Tip: Use
constfor values that won’t change (most things). Useletwhen the value will be reassigned. Avoidvarin modern JavaScript.