How can I pass an array to the filter method in JavaScript?
For example I want to filter an array with another array. Now I have my code working but I am not passing the array, my filter array has a global scope. Is there a way to pass the array to have a cleaner code?
var array = [1, 2, 3, 4, 5];
var filterNumbers = [1, 4];
var result = array.filter(filterData);
function filterData(value) {
return filterNumbers.indexOf(value) === -1;
}