匹配两个日期-TypeScript

时间:2018-12-08 12:26:37

标签: angular typescript

我在看似简单的任务上遇到问题。我需要匹配两个变量,如果匹配则返回true,否则返回false。

我已经制定了检查方法

    isAnyApplicationFromToday(): boolean {
      this.userApplications.forEach(application => {
        if (application.registerDate.toString() == this.today.toString()) {
          return true;
        }
      });
    return false;
  }

但它总是返回false。

有趣的是,如果我console.log(),变量值匹配。

我已经尝试过组合:

if (application.registerDate.toString() === this.today.toString())
if (application.registerDate === this.today)
if (application.registerDate == this.today)

image

有什么想法吗?

编辑:

  isAnyApplicationFromToday(): boolean {
    let isAny = false;
      this.userApplications.forEach(application => {
        if (application.registerDate.toString() === this.today.toString()) {
          isAny = true;
        }
      });
    return isAny;
  }

工作正常。

0 个答案:

没有答案
相关问题