Is there a way to pass an array to the filter method in JavaScript?
I have successfully filtered an array using another array. However, my filter array currently has a global scope. How can I pass the array to make my code cleaner?
var array = [1, 2, 3, 4, 5];
var filterNumbers = [1, 4];
var result = array.filter(filterData);
function filterData(value) {
return filterNumbers.indexOf(value) === -1;
}