JavaScript map() method
This method is used to apply a function on every element in an array and returns a new array of the same size as the input array.
Syntax:
let newArray = oldArray.map((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:
It returns a new array and elements of arrays are the result of the callback 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.