@aheles

Как удалить из массива объекты, у которых значения определённого свойства повторяются?

times() {


          if (this.location &&
              this.model.date &&
              this.model.date.getDay()>=0 &&
              this.location.schedules[this.model.date.getDay()]
          ){

              let times = this.location.schedules[this.model.date.getDay()];

              for(let curTime of this.model.times){

                let isFind = false;

                for(let time of times){

                  if(time.value==curTime){
                    isFind = true;
                  }
                }

                if(!isFind && !this.model.isFreeTime){

                  this.clear();
                  // break;
                }
              }

              let linkTimes = [];

              for(let time of times){

                  linkTimes.push(time.value);
              }

              if(this.model.times){

                  for(let time of times){

                      if(this.model.times.includes(time.value) || this.model.times.length==0)
                        time.disabled = false;
                      else
                        time.disabled = true;
                  }

                  //Проверка на соседствующие
                  for(let index in times){

                      let time = times[index];

                      if(index==0){

                          if(this.model.times.includes(times[1].value))
                              time.disabled = false
                      }
                      else if(index == times.length-1){

                          let subIndex = parseInt(index)-1;

                          if(this.model.times.includes(times[subIndex].value))
                              time.disabled = false
                      }
                      else{

                          if(this.model.times.includes(times[parseInt(index)+1].value))
                              time.disabled = false

                          if(this.model.times.includes(times[parseInt(index)-1].value))
                              time.disabled = false
                      }
                  }
              }

              return times;
          }

          return [];
      }

return times - возвращает массив с значениями
массив такого вида:
61a646705c925081670702.png
нужно убрать те значения, в которых value будет одинаковым
  • Вопрос задан
  • 83 просмотра
Пригласить эксперта
Ответы на вопрос 1
@Kostik_1993
Web Developer
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы