Standard library / assert · on the one-page reference
assert
Stable — wraps the language's own panic mechanism, works identically on native and WebAssembly.
A minimal, practical subset of
Node's
assert module. A failed assertion crashes the program
(uncatchable), the same idiom as C's assert() or an
uncaught Node AssertionError — not integrated with
try/catch.
assert.ok(cond)
bool → void — panics if cond is false.
assert.ok(2 + 2 == 4);
console.log("still running");
assert.equal(a, b)
(T, T) → void — panics with both values shown if they are not equal. Strings compare by bytes.
assert.equal(2 + 2, 4);
assert.equal("hello", "hello");
console.log("still running");