Function: removeFromArray()
removeFromArray<
T
>(array
,element
):void
Removes the first occurrence of an element from an array in place. If the element is not found, the array remains unchanged.
Type Parameters
T
T
The type of elements in the array
Parameters
array
T
[]
The array to remove the element from
element
T
The element to remove
Returns
void
Example
typescript
const items = [1, 2, 3, 2, 4]
removeFromArray(items, 2)
console.log(items) // [1, 3, 2, 4] - only first occurrence removed