You're writing a function that removes an element from an array without mutating the original array and returns the new array. Which array method could help you achieve this?

  • filter()
  • splice()
  • pop()
  • push()
The filter() method creates a new array with all elements that pass the test implemented by the provided function, making it a suitable choice for removing elements from an array without changing the original array. The splice() method can be used for removing elements but mutates the original array. pop() and push() are used for adding/removing elements from the end of an array.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *