![]() |
VOOZH | about |
Lodash _.remove() method is used to remove all elements from the array that predicate returns True and returns the removed elements in an array.
_.remove(array, [predicate]);Example 1: In this example, we are removing and returning the even numbers by using the _.remove() method.
Output:
Original Array [ 1, 3, 5 ]
Removed element array [ 2, 4 ]
Example 2: In this example, we are removing and returning the vowels by using the _.remove() method.
Output:
Original Array [ 'b', 'c', 'd', 'f', 'g', 'h' ]
Removed element array [ 'a', 'e', 'i' ]
Example 3: In this example, we are removing and returning the integers by using the _.remove() method.
Output:
Original Array [ 'a', 'b', 5.6, 'e', 'g', 10.8 ]
Removed element array [ 1, -7, 4 ]