There's no need to use filter here. Since you're not returning anything forEach would be the more appropriate function.
Something along the lines of this should do:
list.forEach(item => $(".generatorContainer[data-generator=" + item + "]").show());
or
list.forEach(function(item){
$(".generatorContainer[data-generator=" + item + "]").show();
});
if you don't like/can't use lambdas
Can I use filter anyway
Yes. But there's really no reason to. If I saw you using filter in this way I would reject your code review.
The use case of filter is to quickly pare down a list of items by passing in a predicate function (a function that answers "does this stay in"). This function's type for an Array<T> would be T => boolean. This filter function will execute the predicate function's code block on every item and then check the return value of that predicate function. If that return value is truthy, it will mark that object that was passed into the predicate function and then return all the objects that resulted in truthy values as a new array. forEach will also execute a function on each parameter, just without doing the extra work of returning a value and managing a new list.
If you do not make use of the returned result from filter, it is nonsensical to use filter. Not only is it useless, it will confuse people reading your code in the future who are trying to understand why you use filter here.
Ultimately the code is the same:
list.filter(item => $(".generatorContainer[data-generator=" + item + "]").show());
The .show() is treated as a side effect (which filter functions really should not have).
.show()method?show()methodshow()methodfilterif not returning anything -forloop orArray.prototype.forEach()will do the trick