Reference

Programming languages

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.

Names & values

TypeScript docs Everyday types ↗

Declare, infer, reassign

TypeScript

const prevents rebinding; let allows it. A type follows the name, or is inferred. Neither makes an object deeply immutable.

Fragment

Fragment inside a function or module.

main.ts
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
const label: string = "north";
let count = 2;
count += 1;

Distinguish shadowing from assignment

TypeScript

let/const are block-scoped. An inner declaration can hide an outer name; assigning without a declaration updates the binding found in that scope. var is function-scoped instead. The inner count below does not replace the outer binding.

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 count = 2;
let inner = 0;

{
  let count = 5;
  inner = count;
}

const outer = count; // 2

Initialize values and defaults

TypeScript

An uninitialized JavaScript let value is undefined. TypeScript’s definite-assignment checks can reject reading a typed variable before assignment. Type annotations do not manufacture a zero/default value.

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 uninitialized; // undefined
let count = 0;
let text = "";
let active = false;

Compare values and object identity

TypeScript

=== compares primitives by value and objects by identity. Equal-looking object literals are different objects. Object.is differs for NaN and signed zero. Neither performs a recursive deep object comparison.

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 first = { count: 2 };
const alias = first;
const other = { count: 2 };

const same = first === alias; // true
const equalShape = first === other; // false

Recognize copying and shared storage

TypeScript

Assigning an object/array shares the same object. Spread creates a shallow copy: nested objects can remain shared. structuredClone supports deeper copies of supported values, but is not a universal clone of arbitrary objects.

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 original = { nested: { count: 2 } };
const alias = original;
const copy = { ...original };

copy.nested.count = 9; // shared nested object