Category
Remove an element from an array.
Time complexity: O(n)
Space complexity: O(n)
The array to remove an element from
The element to remove
The return value of Array.prototype.splice
Array.prototype.splice
Array
const array = [1, 2, 3];pull(array, 2); // [2]console.log(array); // [1, 3]pull(array, 2); // []console.log(array); // [1, 3] Copy
const array = [1, 2, 3];pull(array, 2); // [2]console.log(array); // [1, 3]pull(array, 2); // []console.log(array); // [1, 3]
Remove an element from an array.
Time complexity: O(n)
Space complexity: O(n)