JavaScript filter() method
This method returns a new array containing the elements that pass a certain test performed on an original array.
Syntax:
let newArray = oldArray.filter((currentValue, index, array) {
// Returns element to new Array
});
Parameters:
- currentValue: The current element’s value.
- index: The current element’s array index.
- array: The array object to which the current element belongs.
Return Value:
A new array object containing the filtered elements that satisfied the condition of the function
How to use map and filter simultaneously on an array using JavaScript ?
In this article, we are given an array and the task is to use the filter and map function simultaneously to the given array.