Which method creates a new array with all elements that pass a test implemented by the provided function?
- reduce()
- forEach()
- filter()
- find()
The filter() method creates a new array with all elements that pass the test implemented by the provided function. It's a non-mutating method, meaning it doesn't change the original array. In contrast, reduce(), forEach(), and find() serve different purposes.
Loading...
Related Quiz
- If no case matches in a switch statement and there is no default case, the control is passed to the _________.
- What kind of problem might closures introduce in your code if not used properly?
- Which technology was NOT directly influenced by JavaScript's development?
- The pop() method removes the last element from an array and returns _______.
- What is the purpose of the default case in a switch statement?