JavaScript Environment

QuickJS / ES2020 — what's available out of the box

Built-ins

Scripts run in QuickJS — a full ES2020 engine. Standard built-ins work as expected:

Math.random()                        // random float 0–1
Math.floor(Math.random() * 6) + 1   // random int 1–6

Date.now()                           // Unix timestamp in ms
new Date().getHours()                // current hour (0–23)

parseInt("42px")                     // → 42
parseFloat("3.14")                   // → 3.14

JSON.stringify({ a: 1 })             // → '{"a":1}'
JSON.parse('{"a":1}')                // → { a: 1 }

[1, 2, 3].map(x => x * 2)
"hello".toUpperCase()

Modern syntax is supported: let/const, arrow functions, destructuring, template literals, spread, optional chaining (?.), and try/catch.

Not available

  • setTimeout / setInterval — use wait(ms) instead
  • fetch / XMLHttpRequest — use httpRequest() (Pro)
  • console.log — use print() instead
  • require() / import — no module system