Operators
Operator Precedence (low to high)
Section titled “Operator Precedence (low to high)”pipe— Pipelinecoal— Nullish coalescingor— Logical ORand— Logical ANDeq/neq/not eq/is/instanceof— Equality / Type checklt/gt/le(lt eq) /ge(gt eq) — Comparisonadd/sub— Addition / Subtractionmul/div/mod— Multiplication / Division / Modulopow— Exponentiation- Unary:
not/neg/typeof/await/delete/new - Postfix:
.access /\.optional chaining /[args]call /[\expr]computed access /ascast - Primary: literals, identifiers, brackets
Pipeline
Section titled “Pipeline”data pipe filterdata pipe filter pipe mapdata pipe transform[extra-arg]data pipe .method[arg]Compiles to:
filter(data)map(filter(data))transform(data, extra_arg)data.method(arg)Assignment
Section titled “Assignment”const x be 42let y be 10y be 20Arithmetic
Section titled “Arithmetic”a add b -- a + ba sub b -- a - ba mul b -- a * ba div b -- a / ba mod b -- a % ba pow b -- a ** bneg x -- -xComparison
Section titled “Comparison”eq and is are interchangeable. When the right side is a type name (e.g., string, number, null, or a capitalized class name), it becomes a type check. Otherwise, it becomes a strict equality comparison (===).
For not-equal, use neq or not eq. For less-than-or-equal, both le and lt eq work. For greater-than-or-equal, both ge and gt eq work.
a eq b -- a === ba neq b -- a !== ba not eq b -- a !== b (alternative)a lt b -- a < ba gt b -- a > ba le b -- a <= ba lt eq b -- a <= b (alternative)a ge b -- a >= ba gt eq b -- a >= b (alternative)
-- eq and is can be used interchangeablya eq b -- a === b (value comparison)a is b -- a === b (value comparison)a eq string -- typeof a === "string" (type check)a is string -- typeof a === "string" (type check)Array Ranges
Section titled “Array Ranges”Generate arrays from numeric ranges using .. (inclusive) and ... (exclusive):
const a be [0..5] -- [0, 1, 2, 3, 4, 5]const b be [0...5] -- [0, 1, 2, 3, 4]const c be [1..10] -- [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]const d be [1...10] -- [1, 2, 3, 4, 5, 6, 7, 8, 9]Slicing
Section titled “Slicing”Extract a portion of an array using \ prefix with .. (inclusive) or ... (exclusive) inside bracket access:
const numbers be [0, 1, 2, 3, 4, 5, 6]const middle be numbers[\2..5] -- [2, 3, 4, 5]const partial be numbers[\2...5] -- [2, 3, 4]Splicing
Section titled “Splicing”Replace a portion of an array by assigning to a slice:
numbers[\2..4] be [///a///; ///b///; ///c///]-- numbers is now [0, 1, "a", "b", "c", 5, 6]Computed Access
Section titled “Computed Access”Use \ inside brackets to access array elements or object properties by expression:
const val be arr[\i] -- arr[i]const item be obj[\key] -- obj[key]arr[\0] be ///new/// -- arr[0] = "new"The \ prefix distinguishes computed access from function calls: f[x] is a call, arr[\x] is property access.
Optional Chaining
Section titled “Optional Chaining”Use \. for optional chaining (JS ?.):
const name be user\.name -- user?.nameconst val be obj\.method[1; 2] -- obj?.method(1, 2)const deep be a\.b\.c -- a?.b?.cCompiles to:
const name = user?.name;const val = obj?.method(1, 2);const deep = a?.b?.c;Destructuring
Section titled “Destructuring”Extract values from arrays into variables:
const weather be [///Sunny///; ///Rainy///]const [today; tomorrow] be weather
-- Swap variables[today; tomorrow] be [tomorrow; today]Object destructuring
Section titled “Object destructuring”Use object[...] to destructure properties from an object:
const config be [host be ///localhost///, port be 8080]const object[host; port] be configCompiles to:
const config = { host: "localhost", port: 8080 };const { host, port } = config;Logical
Section titled “Logical”a and b -- a && ba or b -- a || bnot x -- !xNullish Coalescing
Section titled “Nullish Coalescing”The coal operator returns the right-hand side when the left-hand side is null or undefined:
a coal b -- a ?? ba coal b coal c -- a ?? b ?? cCompiles to:
a ?? b;a ?? b ?? c;This is different from or: or treats all falsy values (false, 0, "", null, undefined) as false, while coal only treats null and undefined as “empty”. Use coal when you want to preserve values like 0, false, or "".
const port be config.port coal 3000 -- uses 3000 only if port is null/undefinedconst name be user.name coal ///guest/// -- uses "guest" only if name is null/undefinedType Checks
Section titled “Type Checks”eq and is both work for type checks when followed by a type name.
x is string -- typeof x === "string"x eq string -- typeof x === "string"x is null -- x === nullx is MyClass -- x instanceof MyClassx instanceof Y -- x instanceof Ytypeof x -- typeof x