For the complete documentation index, see llms.txt. This page is also available as Markdown.

Searching & Testing

Find elements, test positions and check predicates. Positions are 1-indexed; "not found" is 0. Equality is strict - no type coercion.

.contains(value)boolean

Whether the array contains value (strict equality).

arr = [1, true, null]
log arr.contains(1)     // true
log arr.contains("1")   // false
log arr.contains(true)  // true

.index(value)number

Position of the first matching element (1-indexed), or 0.

.lastIndex(value)number

Position of the last matching element (1-indexed), or 0.

arr = ["a", "b", "a", "c"]
log arr.index("a")     // 1
log arr.lastIndex("a") // 3
log arr.index("z")     // 0

.some(fn)boolean

Whether fn returns true for any element.

.every(fn)boolean

Whether fn returns true for every element.

.first()unknown / .last()unknown

The first / last element.

.randomOf()unknown

A random element from the array.

Last updated