I want to call the filterArr inside the filterArr. Here is my implementation.
filterArr(array, search) {
var result = [];
array.forEach((a)=> {
var temp = [],
o = {},
found = false;
if (a.name === search) {
this.o.name = a.name;
found = true;
}
if (Array.isArray(a.children)) {
temp = this.filterArr(a.children, search);//***Cannot read property 'filterArr' of undefined***
if (temp.length) {
this.o.children = temp;
found = true;
}
}
if (found) {
result.push(o);
}
});
return result;
}
How to call the filterArr method without any error?