Choose TypeScript, Go, Rust or C++ and find syntax, everyday APIs, standard libraries and tools in one place.
Scope and conventions
TypeScript/Node, Go 1.23+, Rust 2024 and C++23: from a first CLI to files, JSON, HTTP, concurrency and testing. Complete programs are labeled; other examples identify their surrounding code/imports. Optional libraries and version requirements are named in each entry.
T[] and Array<T> describe JavaScript arrays, which grow and shrink. push appends; pop removes the final element or returns undefined. Indexed access outside the array yields undefined; compiler checking depends on options.
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.
main.ts
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
const values: number[] = [2, 5];values.push(8);const first = values[0];const last = values.pop();
Map<K, V> accepts keys of the specified type. get returns undefined for a missing key; has distinguishes a missing key from a stored undefined. Record<K, V> is an object type utility, not a runtime Map.
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.
main.ts
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
const scores = new Map<string, number>();scores.set("north", 24);const found = scores.has("north");const score = scores.get("north");scores.delete("north");
Set stores unique values and preserves insertion order. Object membership uses object identity, not a comparison of all fields. size is a property, not a function.
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.
main.ts
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
const labels = new Set<string>();labels.add("north");labels.add("north");const found = labels.has("north");const size = labels.size; // 1
Array.slice(start, end) creates a shallow copy with an exclusive end index. Nested objects can remain shared. TypedArray.subarray creates a view of the same buffer; it is a different operation from Array.slice.
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.
sort mutates the array and defaults to string-based ordering. A comparator returns negative/zero/positive. toSorted returns a new array (ES2023); it needs runtime support or a polyfill.
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.
main.ts
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
const values = [12, 2, 5];values.sort((a, b) => a - b);const copy = values.toSorted((a, b) => a - b);
Array.map/filter eagerly create arrays. reduce accumulates into one result; an explicit initial value also handles an empty array. These methods are separate from lazy iterator APIs.
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.
main.ts
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
const values = [2, 5, 8];const total = values .filter((n) => n > 3) .map((n) => n * 2) .reduce((sum, n) => sum + n, 0);