remove es-toolkit
Removes elements from an array based on a condition function and returns the removed elements in a new array. It modifies the original array directly.
Usage
remove(arr, shouldRemoveElement)
Use remove when you want to remove elements that meet a specific condition from an array and check what elements were removed. This function modifies the original array while returning the removed elements in a separate array. If you want to keep the original array, use the filter method.
You can also use index and original array information.
Parameters
The array to modify.
A condition function called for each element. Elements for which it returns true are removed.
value: The element currently being processed.index: The index of the current element.array: The original array.
Returns
Returns a new array containing the removed elements.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.