🎯 Removes items at the given index from the array.

Syntax

TypeScript
import { removeAt } from '@opentf/std';

removeAt<T>(arr: T[], index: number, count?: number): T[]

Parameters

NameTypeDescription
arrT[]The source array.
indexnumberThe index to remove items from.
countnumberThe number of items to remove (default 1).

Returns

A new array with the items removed.

Examples

TypeScript
removeAt([1, 2, 3], 1) //=> [1, 3]

removeAt([1, 2, 3, 4], 1, 2) //=> [1, 4]

removeAt([1, 2, 3], 0) //=> [2, 3]
Last updated on
Edit this page