removeAt

🎯 Removes items at the given index from the array.

Syntax

TypeScript
import { removeAt } from '@opentf/std';
removeAt<T>(arr: T[], index: number, options?: { count?: number }): T[]

Parameters

NameTypeDescription
arrT[]The source array.
indexnumberThe index to remove items from.
options{ count?: number }The 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, { count: 2 }) //=> [1, 4]

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

Try it

Last updated on
Edit this page