关于JavaScript中的箭头功能

问题描述

对箭头功能的工作方式感到困惑...在此特定示例中:

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);
    }
  }
}

参加,

let parcels = this.parcels.map(p => {
        if (p.place != this.place) return p;
        return {place: destination,address: p.address};})

我可以说的是p是此箭头函数的参数,但是在此示例中它将被替换为什么变量? move方法中唯一的参数是destination,但这不会取代p ...我听不懂。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)