Skip to content

Standard Builtins, Global Functions, and Timers ​

Standard Built-in Objects ​

The tables below list "the methods you can actually use" rather than every prototype method — parts that match the ES standard are not repeated.

Fundamentals and Collections ​

ObjectHighlights
Objectkeys / values / entries / assign / freeze / create / getPrototypeOf etc.; toString / hasOwnProperty / valueOf on the prototype
ArrayFull prototype method family: map / filter / reduce / find / flat / sort / splice / at etc., plus Array.from / Array.of / Array.isArray
StringPrototype methods: slice / split / replace(All) / padStart / trim / startsWith / match(All) etc.
NumberConstants like MAX_VALUE / MIN_VALUE / EPSILON / MAX_SAFE_INTEGER + Number.parseInt / isInteger / toFixed
Boolean / Symbol / BigIntSymbol("x") creates a unique symbol; BigInt(1n) arbitrary-precision integers
Map / SetFull method family: set / get / has / delete / size / keys / values / entries / forEach
WeakMap / WeakSetWeak-reference collections; keys must be objects
WeakRef / FinalizationRegistryWeak references and finalization callbacks
IteratorIterator helpers (ES2025), works with for...of and spread syntax

Numbers and Math ​

ObjectHighlights
Mathabs / floor / ceil / round / max / min / pow / sqrt / hypot / random / trunc / sign / trig functions, plus constants like PI / E
NumberSee above; numeric literals support 0x / 0b / 0o / exponent / underscore separators
BigIntn-suffixed literals (10n); cannot be mixed with Number in arithmetic

Strings and Regex ​

ObjectHighlights
StringTemplate literals (a${b}) are a language-level feature; prototype methods see the table above
RegExptest / exec / named capture groups / flags gimsuy; String.prototype.replace supports a replacer function
JSONstringify(value, replacer?, space?) and parse(text, reviver?)
js
console.log(JSON.stringify({ ok: true }, null, 2));
console.log("a-b-c".split("-").map(s => s.toUpperCase()));   // [A, B, C]
console.log(/^(\d+)-(\w+)$/.exec("42-abc")[2]);              // abc

Async ​

ObjectHighlights
Promisenew Promise(fn), then / catch / finally, statics resolve / reject / all / allSettled / race / any
async / awaitSupported at the syntax level. Both async function and async arrows (async () => {} / async x => x) work; no top-level await
delayA Gox-specific convenience: delay(ms, value?) returns a Promise that resolves after the delay
js
async function main() {
  let v = await delay(10, "timer done");     // builtin convenience
  console.log(v);
}
main();

// ⚠ Event handlers must be anonymous async function expressions
const onClick = async function () {
  const r = await fetch("https://example.com");
  console.log(r.status);
};

Binary ​

ObjectHighlights
ArrayBufferFixed-length byte buffer, byteLength / slice
TypedArray familyInt8Array / Uint8Array / Uint8ClampedArray / Int16Array / Uint16Array / Int32Array / Uint32Array / Float32Array / Float64Array / BigInt64Array / BigUint64Array
DataViewRead/write any type at an offset: getUint8 / setInt32 / getFloat64 etc., with endianness control
js
let buf = new ArrayBuffer(8);
let view = new DataView(buf);
view.setInt32(0, 258, true);           // little-endian write
console.log(view.getInt32(0, true));   // 258

// fs.readBytesSync returns exactly a byte array
let bytes = fs.readBytesSync("testdata/image_demo.png");

Metaprogramming ​

ObjectHighlights
ProxyIntercept object operations: get / set / has / deleteProperty / apply / construct etc.
ReflectFunctional API mirroring the Proxy traps one to one
evalEvaluate string source in the current scope

Error Types ​

Error / TypeError / RangeError / ReferenceError / SyntaxError / AggregateError — all can be newed, carry message / name / stack, and work with try / catch / finally / throw.

js
try {
  throw new TypeError("bad argument");
} catch (e) {
  console.log(e.name, e.message);      // TypeError bad argument
} finally {
  console.log("cleanup");
}

Temporal Dates and Times ​

No Date

Gox does not implement the legacy Date object; it goes straight to ES's next-generation date/time API Temporal. new Date() in old code throws a ReferenceError.

MemberDescription
Temporal.NowThe only entry point that reads the system clock: instant() / plainDateISO() / plainTimeISO() etc. (methods with the ISO suffix always use the iso8601 calendar)
Temporal.InstantAn absolute point in time (nanosecond precision), e.g. Instant.from("2026-09-19T00:00:00Z")
Temporal.PlainDateA date without a time
Temporal.PlainTimeA time without a date
Temporal.PlainDateTimeDate + time, no time zone
Temporal.ZonedDateTimeA full time with a time zone
Temporal.DurationA duration; can be added, subtracted, and compared
Temporal.PlainYearMonth / PlainMonthDayYear-month / month-day
Temporal.TimeZone / CalendarTime zone and calendar objects
js
let today = Temporal.Now.plainDateISO();
console.log(today.toString());                       // 2026-09-19

let d = Temporal.PlainDate.from("2026-01-31");
console.log(d.add({ days: 1 }).toString());           // 2026-02-01

let due = Temporal.Duration.from({ hours: 2, minutes: 30 });
console.log(due.total({ unit: "minutes" }));          // 150

For the complete method set, see the runtime implementation tutorial.

Global Functions and Constants ​

NameSignatureDescription
parseInt(string, radix?)Parses an integer, stops at the first invalid character
parseFloat(string)Parses a floating-point number
isNaN(value)Is it NaN (performs type coercion)
isFinite(value)Is it a finite number
eval(code)Evaluate string source
NaNconstantNot a Number
InfinityconstantPositive infinity
undefinedconstantUndefined
js
console.log(parseInt("42px", 10));    // 42
console.log(parseFloat("3.14abc"));   // 3.14
console.log(isNaN(NaN), isFinite(Infinity));   // true false

Timers and Scheduling ​

Regular Timers ​

APISignatureDescription
setTimeout(fn, ms) => idRun once after a delay
setInterval(fn, ms) => idRun periodically
clearTimeout(id)Cancel
clearInterval(id)Cancel
requestIdleCallback(fn) => idCallback at idle time; doesn't block the critical path
cancelIdleCallback(id)Cancel an idle callback
delay(ms, value?) => PromiseGox convenience: resolves with the given value after the delay; handy for examples and tests

Strict Timers ​

Regular timers only run when the event loop is idle, so actual intervals can stretch. For time-sensitive scenarios, use the strict timer family:

APIDescription
setStrictTimeoutStrict one-shot timer, scheduled against the target moment rather than "queued"
setStrictIntervalStrict periodic timer
clearStrictTimeoutCancel
clearStrictIntervalCancel
setStrictIntervalModeAdjust the compensation mode of periodic timers

Exit semantics

A script does not exit immediately while timers or async callbacks are still pending — the event loop drives them all to completion. That's why "calling an async function at the top level still shows its printed result a moment later".

Caret blinking in GUI apps

When a window has neither events nor timers, the event pump falls asleep and the input caret freezes. Apps that need continuous blinking can just run an idle requestAnimationFrame loop.