Confused about how arrow functions work...In this particular example:
class VillageState {
constructor(place, parcels) {
this.place = place;
this.parcels = parcels;
}
move(destination) {
if (!roadGraph[this.place].includes(destination)) {
return this;
} else {
let parcels = this.parcels.map(p => {
if (p.place != this.place) return p;
return {place: destination, address: p.address};
}).filter(p => p.place != p.address);
return new VillageState(destination, parcels);
}
}
}
Particulary in,
let parcels = this.parcels.map(p => {
if (p.place != this.place) return p;
return {place: destination, address: p.address};})
What I can tell is that p is the argument of this arrow function but it is going to be replaced for what variable in this example? The only argument in the move method is destination but that's not going to replace p...I can't understand it.