# JavaScript Globals

> The standard JavaScript functions and objects an expression can use (Math, JSON, text, numbers, lists, objects, dates, regular expressions, Intl), with what each returns, and the Node APIs that do not exist.

Source: https://docs.sommatic.ai/en/expressions/reference/javascript-globals/

Expressions run on Node 22 in an isolated context: the ECMAScript standard library is there, Node is not (no `require`, `process`, network or timers). Methods marked Node 22 are recent additions. Every example was run against the deployed engine over the [example context](#example-context) at the end of the page.

## Global functions

Standard ECMAScript functions available without a namespace: URL encoding and number parsing.

- `encodeURIComponent(text)` → `string`: Encodes a value for safe use inside one URL component (a query value or path segment), escaping `&`, `=`, `/`, `?` and spaces. `{{ 'https://example.com/search?q=' + encodeURIComponent($json.body.key) }}` → `"https://example.com/search?q=a%20b%26c"`
- `decodeURIComponent(text)` → `string`: Decodes text produced by `encodeURIComponent`; throws `URIError` on a malformed `%` sequence. `{{ decodeURIComponent($json.body.query.split('=')[1]) }}` → `"Ana Pérez"`
- `encodeURI(text)` → `string`: Encodes a complete URL but keeps reserved characters such as `:`, `/`, `?` and `&`; do not use it for single parameter values. `{{ encodeURI('https://example.com/files/' + $json.body.name + '.pdf') }}` → `"https://example.com/files/ana%20p%C3%A9rez.pdf"`
- `decodeURI(text)` → `string`: Decodes a complete URL encoded with `encodeURI`; escapes that stand for reserved characters stay encoded. `{{ decodeURI('https://example.com/files/ana%20p%C3%A9rez.pdf') }}` → `"https://example.com/files/ana pérez.pdf"`
- `parseInt(text, radix?)` → `number`: Reads the leading integer of a text and stops at the first invalid character; always pass the radix (`10`), and expect `NaN` when the text does not start with a digit. `{{ parseInt($json.body.qty, 10) }}` → `3`
- `parseFloat(text)` → `number`: Reads the leading decimal number of a text; only `.` is accepted as decimal separator, so `"1.234,5"` becomes `1.234`. `{{ parseFloat($json.body.total) }}` → `1234.5`
- `isNaN(value)` → `boolean`: Returns `true` when the value is `NaN` after being coerced to a number, so `isNaN("abc")` is `true`; use `Number.isNaN` for a check without coercion. `{{ isNaN($json.body.total) }}` → `false`
- `isFinite(value)` → `boolean`: Returns `true` when the value, coerced to a number, is finite (`isFinite("12")` is `true`); use `Number.isFinite` to avoid coercion. `{{ isFinite($json.body.total) }}` → `true`

## Math

Static numeric functions and constants. Angles are in radians, and every function returns `NaN` when an argument is not numeric.

- `Math.E` → `number`: Euler's number, the base of natural logarithms (≈ 2.718). `{{ Math.E ** $json.body.score }}` → `2.395040162420149`
- `Math.LN2` → `number`: Natural logarithm of 2 (≈ 0.693). `{{ Math.log($json.body.count) / Math.LN2 }}` → `5.392317422778761`
- `Math.LN10` → `number`: Natural logarithm of 10 (≈ 2.303). `{{ Math.log($json.body.count) / Math.LN10 }}` → `1.6232492903979003`
- `Math.LOG2E` → `number`: Base-2 logarithm of e (≈ 1.443). `{{ Math.LOG2E * Math.log($json.body.count) }}` → `5.392317422778761`
- `Math.LOG10E` → `number`: Base-10 logarithm of e (≈ 0.434). `{{ Math.LOG10E * Math.log($json.body.count) }}` → `1.6232492903979006`
- `Math.PI` → `number`: Ratio of a circle's circumference to its diameter (≈ 3.14159). `{{ Math.PI * $json.body.radius ** 2 }}` → `12.566370614359172`
- `Math.SQRT1_2` → `number`: Square root of 1/2 (≈ 0.707). `{{ Math.SQRT1_2 * $json.body.radius }}` → `1.4142135623730951`
- `Math.SQRT2` → `number`: Square root of 2 (≈ 1.414). `{{ Math.SQRT2 * $json.body.radius }}` → `2.8284271247461903`
- `Math.abs(x)` → `number`: Absolute value of a number. `{{ Math.abs($json.body.amount - 1300) }}` → `65.43299999999999`
- `Math.acos(x)` → `number`: Arccosine in radians, for `x` between -1 and 1. `{{ Math.acos($json.body.score) }}` → `0.508655649762903`
- `Math.acosh(x)` → `number`: Hyperbolic arccosine, for `x` greater than or equal to 1. `{{ Math.acosh($json.body.count) }}` → `4.430675045349548`
- `Math.asin(x)` → `number`: Arcsine in radians, for `x` between -1 and 1. `{{ Math.asin($json.body.score) * 180 / Math.PI }}` → `60.85617804310109`
- `Math.asinh(x)` → `number`: Hyperbolic arcsine. `{{ Math.asinh($json.body.score) }}` → `0.7889641252267557`
- `Math.atan(x)` → `number`: Arctangent in radians, between -π/2 and π/2. `{{ Math.atan($json.body.score) }}` → `0.7179230860695903`
- `Math.atan2(y, x)` → `number`: Angle in radians from the positive x axis to the point (x, y); note that `y` comes first. `{{ Math.atan2($json.body.lat, $json.body.lon) * 180 / Math.PI }}` → `176.36087870201794`
- `Math.atanh(x)` → `number`: Hyperbolic arctangent, for `x` between -1 and 1. `{{ Math.atanh($json.body.score) }}` → `1.347238865532477`
- `Math.cbrt(x)` → `number`: Cube root; works with negative numbers. `{{ Math.cbrt($json.body.count) }}` → `3.4760266448864496`
- `Math.ceil(x)` → `number`: Rounds up to the next integer. `{{ Math.ceil($json.items.length / 2) }}` → `2`
- `Math.clz32(x)` → `number`: Number of leading zero bits in the 32-bit unsigned representation of `x`. `{{ Math.clz32($json.body.count) }}` → `26`
- `Math.cos(x)` → `number`: Cosine of an angle in radians. `{{ Math.cos($json.body.lon * Math.PI / 180) }}` → `0.2744275031057714`
- `Math.cosh(x)` → `number`: Hyperbolic cosine. `{{ Math.cosh($json.body.score) }}` → `1.40628484759911`
- `Math.exp(x)` → `number`: e raised to the power `x`. `{{ Math.exp(-$json.body.retries) }}` → `0.1353352832366127`
- `Math.expm1(x)` → `number`: `e^x - 1`, accurate for values of `x` close to 0. `{{ Math.expm1($json.body.discount) }}` → `0.16183424272828312`
- `Math.floor(x)` → `number`: Rounds down toward -Infinity, so `Math.floor(-1.5)` is -2. `{{ Math.floor($json.body.amount) }}` → `1234`
- `Math.fround(x)` → `number`: Nearest 32-bit single-precision float to `x`. `{{ Math.fround($json.body.amount) }}` → `1234.5670166015625`
- `Math.hypot(...values)` → `number`: Square root of the sum of the squares of its arguments. `{{ Math.hypot($json.body.lat, $json.body.lon) }}` → `74.22175906976338`
- `Math.imul(a, b)` → `number`: 32-bit integer multiplication with overflow, as in C; useful for simple hash functions. `{{ Math.imul($json.body.count, 31) }}` → `1302`
- `Math.log(x)` → `number`: Natural logarithm; `-Infinity` for 0 and `NaN` for negative numbers. `{{ Math.log($json.body.count) }}` → `3.7376696182833684`
- `Math.log10(x)` → `number`: Base-10 logarithm. `{{ Math.floor(Math.log10($json.body.amount)) + 1 }}` → `4`
- `Math.log1p(x)` → `number`: Natural logarithm of `1 + x`, accurate for values of `x` close to 0. `{{ Math.log1p($json.body.discount) }}` → `0.13976194237515868`
- `Math.log2(x)` → `number`: Base-2 logarithm. `{{ Math.ceil(Math.log2($json.items.length)) }}` → `2`
- `Math.max(...values)` → `number`: Largest of its arguments; spread an array with `...`, and note it returns `-Infinity` with no arguments. `{{ Math.max(...$json.items.map(item => item.price)) }}` → `120`
- `Math.min(...values)` → `number`: Smallest of its arguments; spread an array with `...`, and note it returns `Infinity` with no arguments. `{{ Math.min(...$json.items.map(item => item.price)) }}` → `19.99`
- `Math.pow(base, exponent)` → `number`: `base` raised to `exponent`, the same as the `**` operator. `{{ Math.pow(1 + $json.body.discount, 2) }}` → `1.3224999999999998`
- `Math.random()` → `number`: Pseudo-random number in [0, 1); it changes on every run, so avoid it where the result must be reproducible and use `$uuid` for identifiers. `{{ Math.floor(Math.random() * 1000) }}` → `435`
- `Math.round(x)` → `number`: Rounds to the nearest integer, with .5 going toward +Infinity (`Math.round(-2.5)` is -2); for two decimals use `Math.round(x * 100) / 100`. `{{ Math.round($json.body.amount * 100) / 100 }}` → `1234.57`
- `Math.sign(x)` → `number`: Returns 1, -1, 0 or -0 according to the sign of `x`. `{{ Math.sign($json.body.amount - 1000) }}` → `1`
- `Math.sin(x)` → `number`: Sine of an angle in radians. `{{ Math.sin($json.body.lat * Math.PI / 180) }}` → `0.08212984776112466`
- `Math.sinh(x)` → `number`: Hyperbolic sine. `{{ Math.sinh($json.body.score) }}` → `0.9887553148210393`
- `Math.sqrt(x)` → `number`: Square root; `NaN` for negative numbers. `{{ Math.sqrt($json.body.count) }}` → `6.48074069840786`
- `Math.tan(x)` → `number`: Tangent of an angle in radians. `{{ Math.tan($json.body.lat * Math.PI / 180) }}` → `0.08240825272117056`
- `Math.tanh(x)` → `number`: Hyperbolic tangent, between -1 and 1. `{{ Math.tanh($json.body.score) }}` → `0.703097467422122`
- `Math.trunc(x)` → `number`: Drops the fractional part, rounding toward zero (`Math.trunc(-1.5)` is -1). `{{ Math.trunc(-$json.body.amount) }}` → `-1234`

## JSON

Convert between JSON text and values. Use it to read string payloads and to build request bodies.

- `JSON.parse(text, reviver?)` → `any`: Parses JSON text into a value; invalid JSON throws `SyntaxError` and the expression fails. `{{ JSON.parse($json.body.payload).sku }}` → `"SKU-1"`
- `JSON.stringify(value, replacer?, indent?)` → `string`: Serializes a value to JSON text; drops `undefined` and functions, turns `Map` and `Set` into `{}`, writes dates as ISO text, and throws on circular references. `{{ JSON.stringify($json.items.map(item => item.sku)) }}` → `"[\"SKU-1\",\"SKU-2\",\"SKU-3\"]"`

## Number

Conversion, checks and formatting for numbers. Values that arrive as text (form fields, query strings, CSV) must be converted before doing arithmetic.

- `Number(value)` → `number`: Converts a value to a number: `""` and `null` become 0 and any non-numeric text becomes `NaN`; unlike `parseFloat`, the whole text must be numeric. `{{ Number($json.body.total) * Number($json.body.qty) }}` → `3703.5`
- `Number.isFinite(value)` → `boolean`: Returns `true` only for finite values of type number, without coercion. `{{ Number.isFinite(Number($json.body.total)) }}` → `true`
- `Number.isInteger(value)` → `boolean`: Returns `true` when the value is a number with no fractional part. `{{ Number.isInteger($json.body.count) }}` → `true`
- `Number.isNaN(value)` → `boolean`: Returns `true` only when the value is exactly `NaN`, without coercion; use it after `Number()` to detect invalid input. `{{ Number.isNaN(Number($json.body.qty)) }}` → `false`
- `Number.isSafeInteger(value)` → `boolean`: Returns `true` for integers between ±(2^53 − 1); larger numeric ids lose precision, so keep them as text. `{{ Number.isSafeInteger($json.body.count) }}` → `true`
- `Number.parseFloat(text)` → `number`: Same function as the global `parseFloat`. `{{ Number.parseFloat($json.body.total) }}` → `1234.5`
- `Number.parseInt(text, radix?)` → `number`: Same function as the global `parseInt`; always pass the radix. `{{ Number.parseInt($json.body.code.split('-')[1], 10) }}` → `123`
- `Number.EPSILON` → `number`: Smallest difference between 1 and the next representable number (2^-52); use it as tolerance when comparing decimals. `{{ Math.abs($json.items[0].price * 2 - 91) < Number.EPSILON }}` → `true`
- `Number.MAX_SAFE_INTEGER` → `number`: Largest integer that can be represented exactly (2^53 − 1 = 9007199254740991). `{{ $json.body.count <= Number.MAX_SAFE_INTEGER }}` → `true`
- `Number.MIN_SAFE_INTEGER` → `number`: Smallest integer that can be represented exactly (−(2^53 − 1)). `{{ -$json.body.count >= Number.MIN_SAFE_INTEGER }}` → `true`
- `Number.MAX_VALUE` → `number`: Largest finite number (≈ 1.8e308). `{{ $json.body.amount < Number.MAX_VALUE }}` → `true`
- `Number.MIN_VALUE` → `number`: Smallest positive number greater than 0 (≈ 5e-324), not the most negative number. `{{ $json.body.discount > Number.MIN_VALUE }}` → `true`
- `Number.NaN` → `number`: The "not a number" value; it is not equal to itself, so test it with `Number.isNaN`. `{{ $json.body.total ? Number($json.body.total) : Number.NaN }}` → `1234.5`
- `Number.POSITIVE_INFINITY` → `number`: Positive infinity, larger than any number; handy as an "unlimited" default. `{{ $json.body.limit ?? Number.POSITIVE_INFINITY }}` → `null`
- `Number.NEGATIVE_INFINITY` → `number`: Negative infinity, smaller than any number; handy as the starting value when looking for a maximum. `{{ $json.items.reduce((max, item) => Math.max(max, item.price), Number.NEGATIVE_INFINITY) }}` → `120`
- `number.toExponential(digits?)` → `string`: Formats the number in exponential notation and returns text. `{{ $json.body.amount.toExponential(2) }}` → `"1.23e+3"`
- `number.toFixed(digits?)` → `string`: Formats with a fixed number of decimals and returns text, not a number; wrap it in `Number()` if you keep calculating. `{{ $json.body.amount.toFixed(2) }}` → `"1234.57"`
- `number.toLocaleString(locale?, options?)` → `string`: Formats the number with the separators of a locale (uses `Intl.NumberFormat`); pass the locale explicitly, since the default is the server's. `{{ $json.body.amount.toLocaleString('es-CO', { maximumFractionDigits: 0 }) }}` → `"1.235"`
- `number.toPrecision(precision?)` → `string`: Formats with a given number of significant digits and returns text; may switch to exponential notation. `{{ $json.body.score.toPrecision(2) }}` → `"0.87"`
- `number.toString(radix?)` → `string`: Converts the number to text in the given base (2 to 36, default 10). `{{ $json.body.count.toString(16) }}` → `"2a"`

## String

Text conversion and the methods available on every text value. Text is immutable: every method returns a new value and leaves the original unchanged.

- `String(value)` → `string`: Converts any value to text; `null` becomes `"null"` and objects become `"[object Object]"`, so use `JSON.stringify` for objects. `{{ String($json.body.count).padStart(6, '0') }}` → `"000042"`
- `String.fromCharCode(...codes)` → `string`: Builds text from UTF-16 code units. `{{ String.fromCharCode(65 + $json.items.length) }}` → `"D"`
- `String.fromCodePoint(...codePoints)` → `string`: Builds text from Unicode code points, including characters outside the basic plane such as emoji. `{{ String.fromCodePoint(0x2713) + ' ' + $json.body.order_id }}` → `"✓ ORD-1042"`
- `String.raw`template`` → `string`: Template tag that returns the text without processing backslash escapes; handy for regular expressions and Windows paths. `{{ new RegExp(String.raw`^ORD-\d+$`).test($json.body.order_id) }}` → `true`
- `text.length` → `number`: Number of UTF-16 code units in the text; an emoji can count as 2. `{{ $json.body.order_id.length }}` → `8`
- `text.at(index)` → `string`: Character at `index`; negative values count from the end, and out-of-range indexes return `undefined`. `{{ $json.body.order_id.at(-1) }}` → `"2"`
- `text.charAt(index)` → `string`: Character at `index`, or `""` when the index is out of range. `{{ $json.body.name.charAt(0).toUpperCase() + $json.body.name.slice(1) }}` → `"Ana pérez"`
- `text.charCodeAt(index)` → `number`: UTF-16 code unit at `index` (0 to 65535), or `NaN` when out of range. `{{ $json.body.code.charCodeAt(0) }}` → `97`
- `text.codePointAt(index)` → `number`: Unicode code point that starts at `index`, or `undefined` when out of range. `{{ $json.body.name.codePointAt(5) }}` → `233`
- `text.concat(...texts)` → `string`: Joins the arguments to the end of the text; the same as using `+`. `{{ $json.body.order_id.concat('-', $json.customer.country) }}` → `"ORD-1042-CO"`
- `text.endsWith(search, length?)` → `boolean`: Returns `true` when the text ends with `search` (case-sensitive). `{{ $json.customer.email.endsWith('@example.com') }}` → `true`
- `text.includes(search, position?)` → `boolean`: Returns `true` when `search` appears in the text; the comparison is case-sensitive, so normalize the case first. `{{ $json.body.email.toLowerCase().includes('@example.com') }}` → `true`
- `text.indexOf(search, position?)` → `number`: Index of the first occurrence of `search`, or -1 when it is not found. `{{ $json.customer.email.indexOf('@') }}` → `3`
- `text.isWellFormed()` → `boolean`: Returns `true` when the text contains no lone surrogates, i.e. it can be safely encoded as UTF-8. `{{ $json.body.name.isWellFormed() }}` → `true`
- `text.lastIndexOf(search, position?)` → `number`: Index of the last occurrence of `search`, or -1 when it is not found. `{{ $json.body.url.lastIndexOf('/') }}` → `19`
- `text.localeCompare(other, locale?, options?)` → `number`: Compares two texts by the rules of a locale and returns a negative number, 0 or a positive number; use it in `sort` to order names with accents correctly. `{{ $json.items.map(item => item.name).sort((a, b) => a.localeCompare(b, 'es')) }}` → `[ "Keyboard", "Mouse", "Support plan" ]`
- `text.match(regexp)` → `list`: Matches a regular expression: without the `g` flag it returns the first match with its groups, with `g` every match; returns `null` when nothing matches, so guard the result. `{{ ($json.body.url.match(/id=([^&]+)/) || [])[1] }}` → `"ORD-1042"`
- `text.matchAll(regexp)` → `iterator`: Iterator over every match, with groups, of a regex that must have the `g` flag; spread it into a list with `[...]`. `{{ [...$json.body.url.matchAll(/(\w+)=([^&]+)/g)].map(match => match[1]) }}` → `[ "id", "page" ]`
- `text.normalize(form?)` → `string`: Returns the Unicode normalization form (`NFC` by default); with `NFD` plus a regex you can strip accents. `{{ $json.body.name.normalize('NFD').replace(/[\u0300-\u036f]/g, '') }}` → `"ana perez"`
- `text.padEnd(length, filler?)` → `string`: Pads the end of the text with `filler` (a space by default) up to `length`. `{{ $json.items[0].sku.padEnd(10, '.') }}` → `"SKU-1....."`
- `text.padStart(length, filler?)` → `string`: Pads the start of the text with `filler` (a space by default) up to `length`; typical for zero-padded codes. `{{ String($json.body.count).padStart(8, '0') }}` → `"00000042"`
- `text.repeat(count)` → `string`: Repeats the text `count` times. `{{ '*'.repeat($json.body.order_id.length - 4) + $json.body.order_id.slice(-4) }}` → `"****1042"`
- `text.replace(pattern, replacement)` → `string`: Replaces only the first match when `pattern` is text; use a regex with the `g` flag or `replaceAll` to replace every match. `replacement` can be a function or use `$1` for groups. `{{ $json.body.phone.replace(/\D/g, '') }}` → `"573001234567"`
- `text.replaceAll(pattern, replacement)` → `string`: Replaces every match; when `pattern` is a regex it must have the `g` flag, otherwise it throws `TypeError`. `{{ $json.body.key.replaceAll(' ', '_') }}` → `"a_b&c"`
- `text.search(regexp)` → `number`: Index of the first match of a regular expression, or -1. `{{ $json.body.order_id.search(/\d/) }}` → `4`
- `text.slice(start, end?)` → `string`: Extracts the part between `start` and `end` (exclusive); negative indexes count from the end. `{{ $json.body.created_at.slice(0, 10) }}` → `"2026-11-20"`
- `text.split(separator, limit?)` → `list`: Splits the text into a list by `separator` (text or regex). `{{ $json.customer.email.split('@')[1] }}` → `"example.com"`
- `text.startsWith(search, position?)` → `boolean`: Returns `true` when the text starts with `search` (case-sensitive). `{{ $json.body.order_id.startsWith('ORD-') }}` → `true`
- `text.substring(start, end?)` → `string`: Like `slice`, but negative indexes are treated as 0 and the arguments are swapped when `start > end`; prefer `slice`. `{{ $json.body.order_id.substring(4) }}` → `"1042"`
- `text.toLocaleLowerCase(locale?)` → `string`: Converts to lowercase using the rules of a locale (for example Turkish dotted i). `{{ $json.body.name.toLocaleLowerCase('es-CO') }}` → `"ana pérez"`
- `text.toLocaleUpperCase(locale?)` → `string`: Converts to uppercase using the rules of a locale. `{{ $json.body.name.toLocaleUpperCase('es-CO') }}` → `"ANA PÉREZ"`
- `text.toLowerCase()` → `string`: Converts the text to lowercase; combine it with `trim` to normalize emails. `{{ $json.body.email.trim().toLowerCase() }}` → `"ana.perez@example.com"`
- `text.toUpperCase()` → `string`: Converts the text to uppercase. `{{ $json.body.status.toUpperCase() }}` → `"PAID"`
- `text.toWellFormed()` → `string`: Returns a copy where every lone surrogate is replaced with U+FFFD, so the text can be encoded as UTF-8. `{{ $json.body.name.toWellFormed() }}` → `"ana pérez"`
- `text.trim()` → `string`: Removes whitespace and line breaks from both ends. `{{ $json.body.email.trim() }}` → `"Ana.Perez@Example.com"`
- `text.trimEnd()` → `string`: Removes whitespace and line breaks from the end. `{{ $json.body.email.trimEnd() }}` → `" Ana.Perez@Example.com"`
- `text.trimStart()` → `string`: Removes whitespace and line breaks from the start. `{{ $json.body.email.trimStart() }}` → `"Ana.Perez@Example.com "`

## Array

List creation and the methods available on every list. Mutating methods (`sort`, `reverse`, `splice`, `push`, `pop`, `shift`, `unshift`, `fill`, `copyWithin`) change the list in `$json` itself: copy it with `[...list]` first, or use the non-mutating versions (`toSorted`, `toReversed`, `toSpliced`, `with`).

- `Array.isArray(value)` → `boolean`: Reliable check for a list; use it instead of `instanceof Array`, which returns `false` for list literals written inside an expression. `{{ Array.isArray($json.items) ? $json.items.length : 0 }}` → `3`
- `Array.from(source, mapFn?)` → `list`: Creates a list from an iterable or array-like value (`Set`, `Map`, text, `{ length: n }`), optionally mapping each element. `{{ Array.from(new Set($json.body.tags)) }}` → `[ "vip", "b2b" ]`
- `Array.of(...values)` → `list`: Creates a list from its arguments. `{{ Array.of($json.body.order_id, $json.customer.id) }}` → `[ "ORD-1042", "cus_001" ]`
- `list.length` → `number`: Number of elements in the list. `{{ $json.items.length }}` → `3`
- `list.at(index)` → `any`: Element at `index`; negative values count from the end (`at(-1)` is the last element). `{{ $json.items.at(-1).sku }}` → `"SKU-3"`
- `list.concat(...values)` → `list`: Returns a new list with the values (or the elements of lists) appended; does not mutate. `{{ $json.items.concat([{ sku: 'SKU-9', qty: 1, price: 5 }]).length }}` → `4`
- `list.copyWithin(target, start, end?)` → `list`: Mutates the list: copies a slice of it over another position and returns the same list. `{{ [...$json.body.tags].copyWithin(0, 1) }}` → `[ "b2b", "vip", "vip" ]`
- `list.entries()` → `iterator`: Iterator of `[index, element]` pairs; spread it with `[...]` to get a list. `{{ [...$json.items.entries()].map(([index, item]) => (index + 1) + '. ' + item.name) }}` → `[ "1. Keyboard", "2. Mouse", "3. Support plan" ]`
- `list.every(predicate)` → `boolean`: Returns `true` when `predicate` is true for every element (and for an empty list). `{{ $json.items.every(item => item.qty > 0) }}` → `true`
- `list.fill(value, start?, end?)` → `list`: Mutates the list: sets every position between `start` and `end` to `value`. `{{ new Array($json.items.length).fill(0) }}` → `[ 0, 0, 0 ]`
- `list.filter(predicate)` → `list`: New list with the elements for which `predicate` returns true. `{{ $json.items.filter(item => item.category === 'hardware') }}` → `[ { "sku": "SKU-1", "name": "Keyboard", "qty": 2, "price": 45.5, "category": "hardware" }, { "sku": "SKU-2", "name": "Mouse", "qty": 1, "price": 19.99, "category": "hardware" } ]`
- `list.find(predicate)` → `any`: First element that matches `predicate`, or `undefined`; combine it with `?.` before reading a field. `{{ $json.items.find(item => item.sku === 'SKU-2')?.price }}` → `19.99`
- `list.findIndex(predicate)` → `number`: Index of the first element that matches `predicate`, or -1. `{{ $json.items.findIndex(item => item.sku === 'SKU-3') }}` → `2`
- `list.findLast(predicate)` → `any`: Last element that matches `predicate`, or `undefined`. `{{ $json.items.findLast(item => item.category === 'hardware').sku }}` → `"SKU-2"`
- `list.findLastIndex(predicate)` → `number`: Index of the last element that matches `predicate`, or -1. `{{ $json.items.findLastIndex(item => item.category === 'hardware') }}` → `1`
- `list.flat(depth?)` → `list`: New list with nested lists flattened up to `depth` levels (1 by default). `{{ $json.matrix.flat() }}` → `[ 1, 2, 3, 4 ]`
- `list.flatMap(fn)` → `list`: Maps each element and flattens the result one level; return a list to emit several values per element. `{{ $json.items.flatMap(item => Array(item.qty).fill(item.sku)) }}` → `[ "SKU-1", "SKU-1", "SKU-2", "SKU-3" ]`
- `list.forEach(fn)` → `undefined`: Runs `fn` for each element and returns `undefined`, so on its own the expression yields nothing; use `map` or `reduce` to produce a value. `{{ (() => { let units = 0; $json.items.forEach(item => { units += item.qty; }); return units; })() }}` → `4`
- `list.includes(value, fromIndex?)` → `boolean`: Returns `true` when the list contains `value` (finds `NaN`; objects are compared by reference, not by content). `{{ $json.body.tags.includes('vip') }}` → `true`
- `list.indexOf(value, fromIndex?)` → `number`: Index of the first element strictly equal to `value`, or -1. `{{ $json.body.tags.indexOf('b2b') }}` → `1`
- `list.join(separator?)` → `string`: Joins the elements into text with `separator` (`,` by default); `null` and `undefined` become empty text. `{{ $json.items.map(item => item.sku).join(', ') }}` → `"SKU-1, SKU-2, SKU-3"`
- `list.keys()` → `iterator`: Iterator of the indexes; spread it with `[...]` to get a list. `{{ [...$json.items.keys()] }}` → `[ 0, 1, 2 ]`
- `list.lastIndexOf(value, fromIndex?)` → `number`: Index of the last element strictly equal to `value`, or -1. `{{ $json.body.tags.lastIndexOf('vip') }}` → `2`
- `list.map(fn)` → `list`: New list with the result of calling `fn` on every element; to return an object literal from an arrow function, wrap it in parentheses. `{{ $json.items.map(item => ({ sku: item.sku, subtotal: item.qty * item.price })) }}` → `[ { "sku": "SKU-1", "subtotal": 91 }, { "sku": "SKU-2", "subtotal": 19.99 }, { "sku": "SKU-3", "subtotal": 120 } ]`
- `list.pop()` → `any`: Mutates the list: removes the last element and returns it; use `at(-1)` to read it without changing the list. `{{ [...$json.items].pop().sku }}` → `"SKU-3"`
- `list.push(...values)` → `number`: Mutates the list: appends the values and returns the new length, not the list; use `concat` or `[...list, value]` to get a new list. `{{ [...$json.body.tags].push('priority') }}` → `4`
- `list.reduce(fn, initial?)` → `any`: Folds the list into a single value; always pass `initial`, because an empty list without it throws `TypeError`. `{{ $json.items.reduce((total, item) => total + item.qty * item.price, 0) }}` → `230.99`
- `list.reduceRight(fn, initial?)` → `any`: Like `reduce`, but from the last element to the first. `{{ $json.matrix.reduceRight((acc, row) => acc.concat(row), []) }}` → `[ 3, 4, 1, 2 ]`
- `list.reverse()` → `list`: Mutates the list: reverses it in place; use `toReversed` to get a reversed copy. `{{ [...$json.body.tags].reverse() }}` → `[ "vip", "b2b", "vip" ]`
- `list.shift()` → `any`: Mutates the list: removes the first element and returns it; use `[0]` or `at(0)` to read it without changing the list. `{{ [...$json.items].shift().sku }}` → `"SKU-1"`
- `list.slice(start?, end?)` → `list`: Copy of the part between `start` and `end` (exclusive) without mutating; negative indexes count from the end. `{{ $json.items.slice(0, 2) }}` → `[ { "sku": "SKU-1", "name": "Keyboard", "qty": 2, "price": 45.5, "category": "hardware" }, { "sku": "SKU-2", "name": "Mouse", "qty": 1, "price": 19.99, "category": "hardware" } ]`
- `list.some(predicate)` → `boolean`: Returns `true` when `predicate` is true for at least one element. `{{ $json.items.some(item => item.price > 100) }}` → `true`
- `list.sort(compare?)` → `list`: Mutates the list and, without `compare`, sorts the elements as text (`10` comes before `9`); pass `(a, b) => a - b` for numbers and copy first, or use `toSorted`. `{{ [...$json.items].sort((a, b) => b.price - a.price)[0].sku }}` → `"SKU-3"`
- `list.splice(start, deleteCount?, ...items)` → `list`: Mutates the list: removes `deleteCount` elements from `start`, inserts `items`, and returns the removed elements; use `toSpliced` to get a copy. `{{ [...$json.items].splice(1, 1)[0].sku }}` → `"SKU-2"`
- `list.toLocaleString(locale?, options?)` → `string`: Joins the elements with commas, formatting each one with its own `toLocaleString`. `{{ $json.items.map(item => item.price).toLocaleString('es-CO') }}` → `"45,5,19,99,120"`
- `list.toReversed()` → `list`: Reversed copy of the list; does not mutate. `{{ $json.body.tags.toReversed() }}` → `[ "vip", "b2b", "vip" ]`
- `list.toSorted(compare?)` → `list`: Sorted copy of the list; does not mutate. Without `compare` it also sorts as text. `{{ $json.items.toSorted((a, b) => a.price - b.price).map(item => item.sku) }}` → `[ "SKU-2", "SKU-1", "SKU-3" ]`
- `list.toSpliced(start, deleteCount?, ...items)` → `list`: Copy of the list with elements removed or inserted, like `splice` but without mutating. `{{ $json.items.toSpliced(0, 1).length }}` → `2`
- `list.toString()` → `string`: Joins the elements with commas, the same as `join(",")`. `{{ $json.body.tags.toString() }}` → `"vip,b2b,vip"`
- `list.unshift(...values)` → `number`: Mutates the list: inserts the values at the start and returns the new length; use `[value, ...list]` to get a new list. `{{ [...$json.body.tags].unshift('new') }}` → `4`
- `list.values()` → `iterator`: Iterator of the elements; spread it with `[...]` to get a list. `{{ [...$json.body.tags.values()].length }}` → `3`
- `list.with(index, value)` → `list`: Copy of the list with the element at `index` replaced by `value`; does not mutate. `{{ $json.body.tags.with(0, 'gold') }}` → `[ "gold", "b2b", "vip" ]`

## Object

Static functions to inspect, build and transform objects. Functions that freeze or redefine properties mutate their argument, so apply them to a copy (`{ ...obj }`) rather than to `$json`.

- `Object.assign(target, ...sources)` → `object`: Copies the own enumerable properties of `sources` into `target`, mutating it, and returns `target`; pass `{}` as target to get a new object. `{{ Object.assign({}, $json.customer, { tier: 'gold' }) }}` → `{ "id": "cus_001", "email": "ana@example.com", "country": "CO", "tier": "gold" }`
- `Object.create(prototype, descriptors?)` → `object`: Creates an object with the given prototype; `Object.create(null)` gives a dictionary with no inherited keys. `{{ Object.assign(Object.create(null), $json.customer).email }}` → `"ana@example.com"`
- `Object.defineProperties(target, descriptors)` → `object`: Mutates `target`: defines several properties from descriptors; they are non-enumerable unless you set `enumerable: true`. `{{ JSON.stringify(Object.defineProperties({}, { sku: { value: 'SKU-1', enumerable: true } })) }}` → `"{\"sku\":\"SKU-1\"}"`
- `Object.defineProperty(target, key, descriptor)` → `object`: Mutates `target`: defines one property from a descriptor; it is non-enumerable by default, so `JSON.stringify` and `Object.keys` skip it. `{{ Object.keys(Object.defineProperty({ ...$json.customer }, 'internal', { value: true })) }}` → `[ "id", "email", "country" ]`
- `Object.entries(value)` → `list`: List of `[key, value]` pairs of the own enumerable properties. `{{ Object.entries($json.customer).map(([key, value]) => key + '=' + value).join('&') }}` → `"id=cus_001&email=ana@example.com&country=CO"`
- `Object.freeze(value)` → `object`: Makes the object shallowly immutable and returns it; it freezes the argument itself, so freeze a copy, never `$json`. `{{ Object.isFrozen(Object.freeze({ ...$json.customer })) }}` → `true`
- `Object.fromEntries(entries)` → `object`: Builds an object from a list of `[key, value]` pairs or a `Map`; the inverse of `Object.entries`. `{{ Object.fromEntries($json.items.map(item => [item.sku, item.qty])) }}` → `{ "SKU-1": 2, "SKU-2": 1, "SKU-3": 1 }`
- `Object.getOwnPropertyDescriptor(value, key)` → `object`: Descriptor (`value`, `writable`, `enumerable`, `configurable`, or `get`/`set`) of one own property, or `undefined`. `{{ Object.getOwnPropertyDescriptor($json.customer, 'email').writable }}` → `true`
- `Object.getOwnPropertyDescriptors(value)` → `object`: Descriptors of every own property, keyed by property name. `{{ Object.keys(Object.getOwnPropertyDescriptors($json.customer)) }}` → `[ "id", "email", "country" ]`
- `Object.getOwnPropertyNames(value)` → `list`: Names of every own string key, including non-enumerable ones such as `length` on a list. `{{ Object.getOwnPropertyNames($json.body.tags) }}` → `[ "0", "1", "2", "length" ]`
- `Object.getOwnPropertySymbols(value)` → `list`: Own symbol keys; workflow data parsed from JSON never has any. `{{ Object.getOwnPropertySymbols($json.customer).length }}` → `0`
- `Object.getPrototypeOf(value)` → `object`: Prototype of the object, or `null`. `{{ Object.getPrototypeOf($json.customer) === Object.prototype }}` → `true`
- `Object.groupBy(items, keyFn)` → `object` (Node 22): Groups a list into an object whose keys are the results of `keyFn` and whose values are lists of matching elements. `{{ Object.groupBy($json.items, item => item.category) }}` → `{ "hardware": [ { "sku": "SKU-1", "name": "Keyboard", "qty": 2, "price": 45.5, "category": "hardware" }, { "sku": "SKU-2", "name": "Mouse", "qty": 1, "price": 19.99, "category": "hardware" } ], "services": [ { "sku": "SKU-3", "name": "Support plan", "qty": 1, "price": 120, "category": "services" } ] }`
- `Object.hasOwn(value, key)` → `boolean`: Returns `true` when the object has `key` as its own property (not inherited); safer than `in` or `obj.hasOwnProperty`. `{{ Object.hasOwn($json.customer, 'email') }}` → `true`
- `Object.is(a, b)` → `boolean`: SameValue comparison: like `===`, but `NaN` equals `NaN` and `0` differs from `-0`. `{{ Object.is(Number($json.body.qty), 3) }}` → `true`
- `Object.isExtensible(value)` → `boolean`: Returns `true` when new properties can be added to the object. `{{ Object.isExtensible($json.customer) }}` → `true`
- `Object.isFrozen(value)` → `boolean`: Returns `true` when the object is frozen. `{{ Object.isFrozen($json.customer) }}` → `false`
- `Object.isSealed(value)` → `boolean`: Returns `true` when the object is sealed. `{{ Object.isSealed($json.customer) }}` → `false`
- `Object.keys(value)` → `list`: List of the own enumerable keys. `{{ Object.keys($json.customer) }}` → `[ "id", "email", "country" ]`
- `Object.preventExtensions(value)` → `object`: Mutates the object so no new properties can be added, and returns it. `{{ Object.isExtensible(Object.preventExtensions({ ...$json.customer })) }}` → `false`
- `Object.seal(value)` → `object`: Mutates the object so properties cannot be added or removed (existing ones stay writable), and returns it. `{{ Object.isSealed(Object.seal({ ...$json.customer })) }}` → `true`
- `Object.setPrototypeOf(value, prototype)` → `object`: Mutates the object by replacing its prototype; rarely needed in expressions. `{{ Object.getPrototypeOf(Object.setPrototypeOf({ ...$json.customer }, null)) }}` → `null`
- `Object.values(value)` → `list`: List of the own enumerable values. `{{ Object.values($json.customer) }}` → `[ "cus_001", "ana@example.com", "CO" ]`

## Boolean

Truthiness conversion. Flags that arrive as text must be compared explicitly, because any non-empty text is truthy.

- `Boolean(value)` → `boolean`: Converts a value to `true` or `false`: `""`, `0`, `NaN`, `null` and `undefined` are false, while any non-empty text, including `"false"` and `"0"`, is true; compare text flags with `=== "true"`. `{{ Boolean($json.customer.email) && $json.body.paid === 'true' }}` → `true`

## Date

The native `Date` object. Prefer Luxon (`$now`, `$today`) for parsing, time zones and calendar arithmetic. `Date` local getters and setters use the server's time zone, not the user's, so use the `UTC` variants or pass a `timeZone` when formatting.

- `new Date(value?)` → `Date`: Creates a date from ISO text, a timestamp in milliseconds or parts; a date-only text (`"2026-12-01"`) is read as UTC midnight, a date-time without offset as server time, and invalid input gives an Invalid Date. `{{ new Date($json.body.created_at).toISOString() }}` → `"2026-11-20T14:30:00.000Z"`
- `Date.now()` → `number`: Current time as milliseconds since the Unix epoch. `{{ Date.now() - new Date($json.body.created_at).getTime() }}` → `543089959`
- `Date.parse(text)` → `number`: Parses date text and returns its timestamp in milliseconds, or `NaN` when it cannot be parsed. `{{ Date.parse($json.body.due_date) }}` → `1796083200000`
- `Date.UTC(year, monthIndex, day?, hours?, minutes?, seconds?, ms?)` → `number`: Timestamp in milliseconds for a UTC date built from parts; `monthIndex` starts at 0 (January is 0, December is 11). `{{ new Date(Date.UTC(2026, 11, 31)).toISOString() }}` → `"2026-12-31T00:00:00.000Z"`
- `date.getDate()` → `number`: Day of the month (1–31) in the server's time zone. `{{ new Date($json.body.created_at).getDate() }}` → `20`
- `date.getDay()` → `number`: Day of the week (0 = Sunday to 6 = Saturday) in the server's time zone. `{{ new Date($json.body.created_at).getDay() }}` → `5`
- `date.getFullYear()` → `number`: Four-digit year in the server's time zone. `{{ new Date($json.body.created_at).getFullYear() }}` → `2026`
- `date.getHours()` → `number`: Hour (0–23) in the server's time zone. `{{ new Date($json.body.created_at).getHours() }}` → `9`
- `date.getMilliseconds()` → `number`: Milliseconds (0–999) in the server's time zone. `{{ new Date($json.body.created_at).getMilliseconds() }}` → `0`
- `date.getMinutes()` → `number`: Minutes (0–59) in the server's time zone. `{{ new Date($json.body.created_at).getMinutes() }}` → `30`
- `date.getMonth()` → `number`: Month index (0 = January to 11 = December) in the server's time zone; add 1 for the calendar month. `{{ new Date($json.body.created_at).getMonth() + 1 }}` → `11`
- `date.getSeconds()` → `number`: Seconds (0–59) in the server's time zone. `{{ new Date($json.body.created_at).getSeconds() }}` → `0`
- `date.getTime()` → `number`: Timestamp in milliseconds since the Unix epoch; `NaN` for an Invalid Date. `{{ new Date($json.body.created_at).getTime() }}` → `1795185000000`
- `date.getTimezoneOffset()` → `number`: Difference in minutes between UTC and the server's time zone, positive west of UTC (300 for UTC−5). `{{ new Date($json.body.created_at).getTimezoneOffset() }}` → `300`
- `date.getUTCDate()` → `number`: Day of the month (1–31) in UTC. `{{ new Date($json.body.created_at).getUTCDate() }}` → `20`
- `date.getUTCDay()` → `number`: Day of the week (0 = Sunday to 6 = Saturday) in UTC. `{{ new Date($json.body.created_at).getUTCDay() }}` → `5`
- `date.getUTCFullYear()` → `number`: Four-digit year in UTC. `{{ new Date($json.body.created_at).getUTCFullYear() }}` → `2026`
- `date.getUTCHours()` → `number`: Hour (0–23) in UTC. `{{ new Date($json.body.created_at).getUTCHours() }}` → `14`
- `date.getUTCMilliseconds()` → `number`: Milliseconds (0–999) in UTC. `{{ new Date($json.body.created_at).getUTCMilliseconds() }}` → `0`
- `date.getUTCMinutes()` → `number`: Minutes (0–59) in UTC. `{{ new Date($json.body.created_at).getUTCMinutes() }}` → `30`
- `date.getUTCMonth()` → `number`: Month index (0 = January to 11 = December) in UTC. `{{ new Date($json.body.created_at).getUTCMonth() + 1 }}` → `11`
- `date.getUTCSeconds()` → `number`: Seconds (0–59) in UTC. `{{ new Date($json.body.created_at).getUTCSeconds() }}` → `0`
- `date.setDate(day)` → `number`: Mutates the date: sets the day of the month in the server's time zone (overflow rolls into the next month) and returns the new timestamp in milliseconds; wrap it in `new Date(...)` to keep working with a date. `{{ new Date(new Date($json.body.created_at).setDate(new Date($json.body.created_at).getDate() + 30)).toISOString() }}` → `"2026-12-20T14:30:00.000Z"`
- `date.setFullYear(year, monthIndex?, day?)` → `number`: Mutates the date: sets the year in the server's time zone and returns the new timestamp in milliseconds; wrap it in `new Date(...)` to keep working with a date. `{{ new Date($json.body.created_at).setFullYear(2027) }}` → `1826721000000`
- `date.setHours(hours, minutes?, seconds?, ms?)` → `number`: Mutates the date: sets the time of day in the server's time zone and returns the new timestamp in milliseconds; wrap it in `new Date(...)` to keep working with a date. `{{ new Date(new Date($json.body.created_at).setHours(0, 0, 0, 0)).getDate() }}` → `20`
- `date.setMilliseconds(ms)` → `number`: Mutates the date: sets the milliseconds in the server's time zone and returns the new timestamp in milliseconds; wrap it in `new Date(...)` to keep working with a date. `{{ new Date($json.body.created_at).setMilliseconds(0) }}` → `1795185000000`
- `date.setMinutes(minutes, seconds?, ms?)` → `number`: Mutates the date: sets the minutes in the server's time zone and returns the new timestamp in milliseconds; wrap it in `new Date(...)` to keep working with a date. `{{ new Date($json.body.created_at).setMinutes(0, 0, 0) }}` → `1795183200000`
- `date.setMonth(monthIndex, day?)` → `number`: Mutates the date: sets the month index (0–11) in the server's time zone and returns the new timestamp in milliseconds; wrap it in `new Date(...)` to keep working with a date. `{{ new Date($json.body.created_at).setMonth(0) }}` → `1768919400000`
- `date.setSeconds(seconds, ms?)` → `number`: Mutates the date: sets the seconds in the server's time zone and returns the new timestamp in milliseconds; wrap it in `new Date(...)` to keep working with a date. `{{ new Date($json.body.created_at).setSeconds(0, 0) }}` → `1795185000000`
- `date.setTime(timestamp)` → `number`: Mutates the date: sets the whole date from a timestamp in milliseconds and returns the new timestamp in milliseconds; wrap it in `new Date(...)` to keep working with a date. `{{ new Date(new Date().setTime(Date.parse($json.body.due_date))).toISOString() }}` → `"2026-12-01T00:00:00.000Z"`
- `date.setUTCDate(day)` → `number`: Mutates the date: sets the day of the month in UTC and returns the new timestamp in milliseconds; wrap it in `new Date(...)` to keep working with a date. `{{ new Date(new Date($json.body.created_at).setUTCDate(new Date($json.body.created_at).getUTCDate() + 30)).toISOString() }}` → `"2026-12-20T14:30:00.000Z"`
- `date.setUTCFullYear(year, monthIndex?, day?)` → `number`: Mutates the date: sets the year in UTC and returns the new timestamp in milliseconds; wrap it in `new Date(...)` to keep working with a date. `{{ new Date(new Date($json.body.created_at).setUTCFullYear(2027)).toISOString() }}` → `"2027-11-20T14:30:00.000Z"`
- `date.setUTCHours(hours, minutes?, seconds?, ms?)` → `number`: Mutates the date: sets the time of day in UTC and returns the new timestamp in milliseconds; wrap it in `new Date(...)` to keep working with a date. `{{ new Date(new Date($json.body.created_at).setUTCHours(0, 0, 0, 0)).toISOString() }}` → `"2026-11-20T00:00:00.000Z"`
- `date.setUTCMilliseconds(ms)` → `number`: Mutates the date: sets the milliseconds in UTC and returns the new timestamp in milliseconds; wrap it in `new Date(...)` to keep working with a date. `{{ new Date($json.body.created_at).setUTCMilliseconds(0) }}` → `1795185000000`
- `date.setUTCMinutes(minutes, seconds?, ms?)` → `number`: Mutates the date: sets the minutes in UTC and returns the new timestamp in milliseconds; wrap it in `new Date(...)` to keep working with a date. `{{ new Date(new Date($json.body.created_at).setUTCMinutes(0, 0, 0)).toISOString() }}` → `"2026-11-20T14:00:00.000Z"`
- `date.setUTCMonth(monthIndex, day?)` → `number`: Mutates the date: sets the month index (0–11) in UTC and returns the new timestamp in milliseconds; wrap it in `new Date(...)` to keep working with a date. `{{ new Date(new Date($json.body.created_at).setUTCMonth(11, 31)).toISOString() }}` → `"2026-12-31T14:30:00.000Z"`
- `date.setUTCSeconds(seconds, ms?)` → `number`: Mutates the date: sets the seconds in UTC and returns the new timestamp in milliseconds; wrap it in `new Date(...)` to keep working with a date. `{{ new Date($json.body.created_at).setUTCSeconds(0, 0) }}` → `1795185000000`
- `date.toDateString()` → `string`: Date part as English text in the server's time zone (`"Fri Nov 20 2026"`). `{{ new Date($json.body.created_at).toDateString() }}` → `"Fri Nov 20 2026"`
- `date.toISOString()` → `string`: ISO 8601 text in UTC (`"2026-11-20T14:30:00.000Z"`); throws `RangeError` for an Invalid Date. `{{ new Date($json.body.created_at).toISOString() }}` → `"2026-11-20T14:30:00.000Z"`
- `date.toJSON()` → `string`: Same as `toISOString`, but returns `null` for an Invalid Date; `JSON.stringify` calls it. `{{ new Date($json.body.created_at).toJSON() }}` → `"2026-11-20T14:30:00.000Z"`
- `date.toLocaleDateString(locale?, options?)` → `string`: Date part formatted for a locale; pass `timeZone` in `options` to avoid the server's zone. `{{ new Date($json.body.created_at).toLocaleDateString('es-CO', { timeZone: 'America/Bogota' }) }}` → `"20/11/2026"`
- `date.toLocaleString(locale?, options?)` → `string`: Date and time formatted for a locale; pass `timeZone` in `options` to avoid the server's zone. `{{ new Date($json.body.created_at).toLocaleString('es-CO', { timeZone: 'America/Bogota' }) }}` → `"20/11/2026, 9:30:00 a. m."`
- `date.toLocaleTimeString(locale?, options?)` → `string`: Time part formatted for a locale; pass `timeZone` in `options` to avoid the server's zone. `{{ new Date($json.body.created_at).toLocaleTimeString('en-US', { timeZone: 'America/New_York' }) }}` → `"9:30:00 AM"`
- `date.toString()` → `string`: Full English text with the server's time zone; not meant for storage or exchange. `{{ new Date($json.body.created_at).toString() }}` → `"Fri Nov 20 2026 09:30:00 GMT-0500 (Colombia Standard Time)"`
- `date.toTimeString()` → `string`: Time part as text with the server's time zone. `{{ new Date($json.body.created_at).toTimeString() }}` → `"09:30:00 GMT-0500 (Colombia Standard Time)"`
- `date.toUTCString()` → `string`: RFC 7231 text in UTC (`"Fri, 20 Nov 2026 14:30:00 GMT"`), the format of HTTP headers. `{{ new Date($json.body.created_at).toUTCString() }}` → `"Fri, 20 Nov 2026 14:30:00 GMT"`

## RegExp

Regular expressions, written as literals (`/ORD-\d+/i`) or built with `RegExp`. The text methods that take a pattern (`match`, `matchAll`, `replace`, `replaceAll`, `search`, `split`) are listed under String.

- `new RegExp(pattern, flags?)` → `RegExp`: Builds a regular expression from text, for patterns that include dynamic values; escape special characters that come from data, and double the backslashes inside the text. `{{ new RegExp('^' + $json.customer.country + '-', 'i').test('co-1042') }}` → `true`
- `regexp.test(text)` → `boolean`: Returns `true` when the text matches; with the `g` or `y` flag it advances `lastIndex`, so repeated calls on the same regex can alternate results. `{{ /^[^@\s]+@[^@\s]+\.[a-z]{2,}$/i.test($json.customer.email) }}` → `true`
- `regexp.exec(text)` → `list`: Returns the first match as a list (full match, then groups) with `index` and named groups in `.groups`, or `null` when nothing matches. `{{ /ORD-(?<number>\d+)/.exec($json.body.order_id).groups.number }}` → `"1042"`

## Map and Set

Keyed collections (`Map`) and collections of unique values (`Set`). Both serialize as `{}`, so convert the result with `Object.fromEntries`, `Array.from` or `[...]` before the expression returns.

- `new Map(entries?)` → `Map`: Creates a map from `[key, value]` pairs; keys can be of any type and keep insertion order. `{{ new Map($json.items.map(item => [item.sku, item])).get('SKU-2').price }}` → `19.99`
- `Map.groupBy(items, keyFn)` → `Map` (Node 22): Groups a list into a `Map` whose keys are the results of `keyFn`; unlike `Object.groupBy`, keys are not converted to text. `{{ Object.fromEntries(Map.groupBy($json.items, item => item.category)) }}` → `{ "hardware": [ { "sku": "SKU-1", "name": "Keyboard", "qty": 2, "price": 45.5, "category": "hardware" }, { "sku": "SKU-2", "name": "Mouse", "qty": 1, "price": 19.99, "category": "hardware" } ], "services": [ { "sku": "SKU-3", "name": "Support plan", "qty": 1, "price": 120, "category": "services" } ] }`
- `map.get(key)` → `any`: Value stored under `key`, or `undefined`. `{{ new Map(Object.entries($json.customer)).get('country') }}` → `"CO"`
- `map.set(key, value)` → `Map`: Mutates the map: stores `value` under `key` and returns the map, so calls can be chained. `{{ new Map().set('total', $json.items.length).get('total') }}` → `3`
- `map.has(key)` → `boolean`: Returns `true` when the map contains `key`. `{{ new Map($json.items.map(item => [item.sku, item.qty])).has('SKU-3') }}` → `true`
- `map.delete(key)` → `boolean`: Mutates the map: removes `key` and returns `true` if it existed. `{{ new Map(Object.entries($json.customer)).delete('id') }}` → `true`
- `map.clear()` → `undefined`: Mutates the map: removes every entry. `{{ new Map(Object.entries($json.customer)).clear() }}` → `undefined`
- `map.size` → `number`: Number of entries in the map. `{{ new Map($json.items.map(item => [item.category, item])).size }}` → `2`
- `map.keys()` → `iterator`: Iterator of the keys in insertion order; spread it with `[...]`. `{{ [...new Map($json.items.map(item => [item.category, item])).keys()] }}` → `[ "hardware", "services" ]`
- `map.values()` → `iterator`: Iterator of the values in insertion order; spread it with `[...]`. `{{ [...new Map($json.items.map(item => [item.sku, item.price])).values()] }}` → `[ 45.5, 19.99, 120 ]`
- `map.entries()` → `iterator`: Iterator of `[key, value]` pairs; pass it to `Object.fromEntries` to get an object. `{{ Object.fromEntries(new Map(Object.entries($json.customer)).entries()) }}` → `{ "id": "cus_001", "email": "ana@example.com", "country": "CO" }`
- `map.forEach(fn)` → `undefined`: Runs `fn(value, key)` for each entry and returns `undefined`. `{{ (() => { const parts = []; new Map(Object.entries($json.customer)).forEach((value, key) => parts.push(key + ':' + value)); return parts.join(';'); })() }}` → `"id:cus_001;email:ana@example.com;country:CO"`
- `new Set(values?)` → `Set`: Creates a set of unique values (objects are compared by reference); spread it with `[...]` to deduplicate a list. `{{ [...new Set($json.body.tags)] }}` → `[ "vip", "b2b" ]`
- `set.add(value)` → `Set`: Mutates the set: adds `value` and returns the set, so calls can be chained. `{{ new Set($json.body.tags).add('priority').size }}` → `3`
- `set.has(value)` → `boolean`: Returns `true` when the set contains `value`; faster than `includes` on large lists. `{{ new Set($json.body.tags).has('vip') }}` → `true`
- `set.delete(value)` → `boolean`: Mutates the set: removes `value` and returns `true` if it existed. `{{ new Set($json.body.tags).delete('b2b') }}` → `true`
- `set.clear()` → `undefined`: Mutates the set: removes every value. `{{ new Set($json.body.tags).clear() }}` → `undefined`
- `set.size` → `number`: Number of unique values in the set. `{{ new Set($json.items.map(item => item.category)).size }}` → `2`
- `set.values()` → `iterator`: Iterator of the values in insertion order; spread it with `[...]`. `{{ [...new Set($json.body.tags).values()] }}` → `[ "vip", "b2b" ]`
- `set.keys()` → `iterator`: Same as `values()`; it exists for symmetry with `Map`. `{{ [...new Set($json.body.tags).keys()] }}` → `[ "vip", "b2b" ]`
- `set.entries()` → `iterator`: Iterator of `[value, value]` pairs, for symmetry with `Map`. `{{ [...new Set($json.body.tags).entries()].length }}` → `2`
- `set.forEach(fn)` → `undefined`: Runs `fn(value)` for each value and returns `undefined`. `{{ (() => { const upper = []; new Set($json.body.tags).forEach(tag => upper.push(tag.toUpperCase())); return upper; })() }}` → `[ "VIP", "B2B" ]`
- `set.union(other)` → `Set` (Node 22): New set with the values of both sets. `{{ [...new Set($json.body.tags).union(new Set(['priority']))] }}` → `[ "vip", "b2b", "priority" ]`
- `set.intersection(other)` → `Set` (Node 22): New set with the values present in both sets. `{{ [...new Set($json.body.tags).intersection(new Set(['vip', 'retail']))] }}` → `[ "vip" ]`
- `set.difference(other)` → `Set` (Node 22): New set with the values of this set that are not in `other`. `{{ [...new Set($json.body.tags).difference(new Set(['vip']))] }}` → `[ "b2b" ]`
- `set.symmetricDifference(other)` → `Set` (Node 22): New set with the values that are in exactly one of the two sets. `{{ [...new Set($json.body.tags).symmetricDifference(new Set(['vip', 'retail']))] }}` → `[ "b2b", "retail" ]`
- `set.isSubsetOf(other)` → `boolean` (Node 22): Returns `true` when every value of this set is in `other`. `{{ new Set($json.body.tags).isSubsetOf(new Set(['vip', 'b2b', 'retail'])) }}` → `true`
- `set.isSupersetOf(other)` → `boolean` (Node 22): Returns `true` when every value of `other` is in this set. `{{ new Set($json.body.tags).isSupersetOf(new Set(['vip'])) }}` → `true`
- `set.isDisjointFrom(other)` → `boolean` (Node 22): Returns `true` when the two sets have no values in common. `{{ new Set($json.body.tags).isDisjointFrom(new Set(['blocked'])) }}` → `true`

## Intl

Locale-aware formatting with full ICU data, so every locale and time zone is available. Always pass the locale, and for dates the `timeZone`, because the defaults are the server's.

- `new Intl.NumberFormat(locale?, options?).format(value)` → `string`: Formats numbers, currencies (`style: "currency"`, `currency`), percentages (`style: "percent"`) and units for a locale. `{{ new Intl.NumberFormat('es-CO', { style: 'currency', currency: 'COP' }).format($json.body.amount) }}` → `"$ 1.234,57"`
- `new Intl.DateTimeFormat(locale?, options?).format(date)` → `string`: Formats a `Date` for a locale (`dateStyle`, `timeStyle` or individual fields); pass `timeZone`, otherwise the server's zone is used. `{{ new Intl.DateTimeFormat('es-CO', { dateStyle: 'long', timeZone: 'America/Bogota' }).format(new Date($json.body.created_at)) }}` → `"20 de noviembre de 2026"`
- `new Intl.RelativeTimeFormat(locale?, options?).format(value, unit)` → `string`: Formats a relative time such as "in 3 days" or "2 hours ago"; with `numeric: "auto"` it uses words like "yesterday". `{{ new Intl.RelativeTimeFormat('es', { numeric: 'auto' }).format(-$json.body.retries, 'day') }}` → `"anteayer"`
- `new Intl.ListFormat(locale?, options?).format(list)` → `string`: Joins a list of texts with the locale's conjunction ("a, b y c") or disjunction (`type: "disjunction"`). `{{ new Intl.ListFormat('es', { type: 'conjunction' }).format($json.items.map(item => item.name)) }}` → `"Keyboard, Mouse y Support plan"`
- `new Intl.PluralRules(locale?, options?).select(count)` → `string`: Returns the plural category of a number for a locale (`"one"`, `"other"`, …), to pick the right word form. `{{ new Intl.PluralRules('en-US').select($json.items.length) === 'one' ? 'item' : 'items' }}` → `"items"`
- `new Intl.Collator(locale?, options?).compare` → `function`: Locale-aware comparison function for `sort`; `sensitivity: "base"` ignores case and accents. `{{ $json.items.map(item => item.name).sort(new Intl.Collator('es', { sensitivity: 'base' }).compare) }}` → `[ "Keyboard", "Mouse", "Support plan" ]`

## Not available

- `require`: There is no module system. Use the built-ins on this page, lodash as `_`, or a Code node (`code.js`) for logic that needs more.
- `process`: Not defined. Pass the values you need from the trigger or a previous node and read them from `$json`.
- `Buffer`: Not defined. Use `$base64Encode` / `$base64Decode` for Base64, and a Code node for binary data.
- `atob`: Not defined. Use `$base64Decode(text)`.
- `btoa`: Not defined. Use `$base64Encode(text)`.
- `setTimeout`: Not defined: expressions are synchronous and limited to 100 ms. Use a `flow.wait` node to pause a workflow.
- `setInterval`: Not defined. For repeated runs use a `cron.trigger` trigger; for retries, the node's retry settings.
- `fetch`: Not defined: expressions cannot make network calls. Use an `io.http` node and read its output in the next node.
- `structuredClone`: Not defined. Use `_.cloneDeep(value)`, or `JSON.parse(JSON.stringify(value))` for plain JSON data.
- `URL`: Not defined. Build URLs with `encodeURIComponent` and read their parts with `split` or a regular expression.
- `URLSearchParams`: Not defined. Use `$toQueryString(object)` to build a query string, or `Object.entries` with `encodeURIComponent`.
- `TextEncoder`: Not defined. Text is handled as JavaScript strings; use a Code node when you need UTF-8 bytes.
- `TextDecoder`: Not defined. Decode bytes in a Code node, or use `$base64Decode` for Base64 text.
- `crypto`: Not defined. Use `$uuid` for unique identifiers.
- `async / await`: Expressions are synchronous: `await` is a syntax error and an async function returns a Promise that is never awaited (it becomes `{}` in text). Do asynchronous work in a node.
- `console.log`: Accepted but discarded, and `console.error` / `console.warn` do not exist. To inspect a value, return it from the expression and check the node's output in the run.

## Example context

The examples of this page run over this input as `$json`. They do not change it: each example runs in a fresh context.

```json
{
  "$json": {
    "body": {
      "email": " Ana.Perez@Example.com ",
      "name": "ana pérez",
      "order_id": "ORD-1042",
      "created_at": "2026-11-20T14:30:00Z",
      "due_date": "2026-12-01",
      "total": "1234.5",
      "amount": 1234.567,
      "qty": "3",
      "discount": 0.15,
      "status": "paid",
      "phone": "+57 300 123 4567",
      "tags": [
        "vip",
        "b2b",
        "vip"
      ],
      "key": "a b&c",
      "url": "https://example.com/orders?id=ORD-1042&page=2",
      "query": "name=Ana%20P%C3%A9rez",
      "payload": "{\"sku\":\"SKU-1\",\"qty\":2}",
      "note": "Line 1\nLine 2",
      "code": "abc-123",
      "score": 0.8734,
      "lat": 4.711,
      "lon": -74.0721,
      "count": 42,
      "radius": 2,
      "paid": "true",
      "retries": 2
    },
    "items": [
      {
        "sku": "SKU-1",
        "name": "Keyboard",
        "qty": 2,
        "price": 45.5,
        "category": "hardware"
      },
      {
        "sku": "SKU-2",
        "name": "Mouse",
        "qty": 1,
        "price": 19.99,
        "category": "hardware"
      },
      {
        "sku": "SKU-3",
        "name": "Support plan",
        "qty": 1,
        "price": 120,
        "category": "services"
      }
    ],
    "customer": {
      "id": "cus_001",
      "email": "ana@example.com",
      "country": "CO"
    },
    "matrix": [
      [
        1,
        2
      ],
      [
        3,
        4
      ]
    ]
  }
}
```
