🎯 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
| Name | Type | Description |
|---|---|---|
| arr | T[] | The source array. |
| index | number | The index to remove items from. |
| 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, 2) //=> [1, 4] removeAt([1, 2, 3], 0) //=> [2, 3]