Trying to find the intersection of two arrays, why am I getting TS2339:Property \'collection\' does not exist on type \'void\'
?
All arrays are declared
Using a function
takes the this
from the caller (something in forEach
in your case); using =>
takes the this
from the outer scope. Thus use:
this.locations.forEach(location => {
this.collection.locations.forEach(id => {
if(location._id === id) {
this.display.push(location);
}
});
});
I recommend the following readings: