API reference / @evolu/common / Array / shiftArray

Function: shiftArray()

function shiftArray<T>(array): T;

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

Shifts an item from a non-empty mutable array, guaranteed to return T.

Mutates the original array.

Example

const arr: NonEmptyArray<number> = [1, 2, 3];
shiftArray(arr); // 1
arr; // [2, 3]

Type Parameters

Type Parameter
T

Parameters

ParameterType
array[T, ...T[]]

Returns

T

Was this page helpful?