I have 2 arrays like the following:
Arr1 = [{"test":{"active":false},"id":1},{"test":{"active":true},"id":2}]
Arr2 = [{"test":{"active":true},"id":1},{"test":{"active":true},"id":2}]
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable, Subject, throwError } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
getOverviewCards(): any {
return this.http
.get<OverviewCardList>(this.overviewCardUrl)
.pipe(map(overviewCards => overviewCards.cardList))
.pipe(catchError((error: any) => throwError(error)));
}
this.Arr1.filter(element => this.Arr2.includes(element.test.active))
I know I did wrong, I am using typescript.
Now, I want to check 'active' variable in both arrays. That is, active in first object of arr1 with arr2 and so on. If the both arrays are same it should return true else false. In the above array examples it should return false.
Can anyone please help me with the quickest method. Thanks.