I want to use array.filter(my_func()) when processing 5 different arrays of user inputs to elegantly return the array without the element the user just deleted, with a private filterInput class variable. However, my_func() when used as an inner call doesn't have "this" context.
Is there a better way to do this? Would rather not write the same filter function in 5 different callers just to keep scope.
MyClass
private inputArray1: string[];
...
private filterInput: string;
...
private filterFunc(element, index, array) {
return (element !== this.filterInput);
}
...
public caller1(input: string) {//this is called from the onclick() in the HTML
this.filterInput = input;
this.inputArray1 = this.inputArray1.filter(this.filterFunc());
}
Anyone know how to accomplish this without scrapping the filter utility and just writing my own using search then return slice1 + slice2?