The filter() method creates a new array with all the elements that pass the test implemented by the callback() function and it does not change the original array. Internally, the filter() method iterates over each element of the array and pass each element to the callback function. If the callback function returns true, it includes the element in the return array.
Using ECMAScript 6 code
Using ECMAScript 7 code
Removing specific item suing splice()
In the above example, find the index of the array element you want to remove using indexOf(), and then remove that index with splice() method. The second parameter of splice() is the number of elements to remove.