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.
if tests truthiness. a && b skips b when a is falsy; a || b skips b when a is truthy. They return a selected operand, not necessarily a boolean. ! returns a boolean. condition ? a : b evaluates only the selected branch.
Fragment
Function declaration.
main.ts
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
function sign(n: number): string { if (n === 0) { return "zero"; } return n > 0 ? "positive" : "negative";}
for…of visits values; for await…of awaits values from an async iterable. A three-part for counts explicitly. break exits; continue skips to the next iteration.
Fragment
Fragment inside a function.
main.ts
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
const names = ["north", "west"];for (const name of names) { console.log(name);}for (let i = 0; i < 2; i++) {}
switch selects a matching case; execution can fall through without break/return. A switch on a discriminant can also narrow a union. JavaScript switch is not general structural pattern matching.
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.
while checks before the body; do…while checks after it. break leaves the nearest loop; continue starts its next iteration. return leaves the entire 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+
let n = 3;while (n > 0) { n -= 1;}do { n += 1;} while (n < 1);