JavaScript quick reference
JavaScript on Node.js 22: values, let/const, control flow, functions, arrays and objects, strings, async code, stdin and files — and how a program runs in Zerethon IDE.
Written for Node.js 22. Examples that show an output were run in the Zerethon sandbox (Node.js 22) on 2026-10-20.
Basics
-
Hello, World
The smallest Node.js program, and how
console.log()prints. -
Variables and types
constandlet, numbers, strings, booleans,null/undefined, and converting between types. -
Conditions and loops
if/else,switch,for,for…of,while, and the ternary operator. -
Functions
Function declarations, arrow functions, default parameters, rest parameters and destructuring.
Data
-
Arrays, objects, Map and Set
Arrays and their methods, sorting correctly, objects as records, and
Map/Set. -
Strings and regular expressions
Template literals, common string methods, splitting and joining, and regular expressions.
-
Promises and async / await
Wait for asynchronous work with
async/await, run tasks together withPromise.all, and handle errors.
Input and files
-
Reading input (stdin)
Read what you type in the IDE's Input tab: all at once with
fs.readFileSync(0), or line by line. -
Reading and writing files
Read project files with
fs; write temporary files under/tmp. -
Modules and several files
Split a program into files with
require/module.exportsorimport/export; no npm packages.
In Zerethon IDE
-
Running JavaScript in Zerethon IDE
What Run does with your project, the time limit, input, tests, and what a run cannot do.
-
Common errors
What
ReferenceError,TypeError,SyntaxErrorand “Cannot find module” mean and how to fix them. -
Official documentation
Where to read more: MDN for the language, the Node.js 22 docs for
fs,processand other built-in modules.