remove
@guoba-ai/utils / array / remove
Function: remove()
function remove<T>(array, predicate): T[];Defined in: array.ts:118
Remove elements from an array in-place that match the predicate.
Type Parameters
T
T
Parameters
array
T[]
The array to modify
predicate
(v) => boolean
Function that returns true for elements to remove
Returns
T[]
An array of removed elements
Example
const arr = [1, 2, 3, 4, 5]
remove(arr, v => v % 2 === 0) // [2, 4]
// arr is now [1, 3, 5]