API reference / @evolu/common / Array / appendToArray

Function: appendToArray()

function appendToArray<T>(array, item): readonly [T, T];

Defined in: packages/common/src/Array.ts:155

Appends an item to an array, returning a new non-empty readonly array.

Accepts both mutable and readonly arrays. Does not mutate the original array.

Example

appendToArray([1, 2, 3], 4); // [1, 2, 3, 4]

Type Parameters

Type Parameter
T

Parameters

ParameterType
arrayreadonly T[]
itemT

Returns

readonly [T, T]

Was this page helpful?