Filter method in javascript
Array.filter()
Filter method is used to filtering a array based on a condition. This method takes a callback method inside this method we need to give a condition if condition is true then return value see example bellow
Example
let myArray = [1, 2, 4, 3, 5, 6, 7, 8, 9]
let result = myArray.filter((x) => x <= 5);
console.log(result);
In this example we filter this array by using this condition number <= 5