Skip to main content

Arrays and Objects

Arrays hold multiple values. Objects hold named properties. Some functions and connected-record references return arrays or arrays of objects.

Arrays

Use square brackets to access an item by index.

A1 = [1, 2, 3, 4]
A1[0]

This returns 1.

caution

AnyDB uses 0-based indexing for arrays. The first item is A1[0], not A1[1].

Objects

Formulas can return objects with named properties.

A1 = { name: "John", age: 30 }
A1.name

Arrays of Objects

When an array contains objects, combine array indexing and dot notation.

A1 = [{ name: "John", age: 30 }, { name: "Adam", age: 45 }]
A1[0].name

This returns John.