Syntax:
let newArray = Oldarray.filter(callback(element, index, array));
Explanation:
- The filter method returns a new array from the filtered items from the oldArray
- Items are filtered according to some condition
- To do so a callback function is used
- The callback function takes 3 arguments:
- element: The current element
- index: the index of the current element
- array: the old array
Leave a Reply