filter json array by key in angular 9

Solutions on MaxInterview for filter json array by key in angular 9 by the best coders in the world

showing results for - "filter json array by key in angular 9"
Sebestian
10 Aug 2018
1var heroes = [
2	{name: “Batman”, franchise: “DC”},
3	{name: “Ironman”, franchise: “Marvel”},
4	{name: “Thor”, franchise: “Marvel”},
5	{name: “Superman”, franchise: “DC”}
6];
7
8var marvelHeroes =  heroes.filter(function(hero) {
9	return hero.franchise == “Marvel”;
10});
Bryce
17 Mar 2019
1const data = [
2  {
3    name: 'Bob',
4    gender: 'male',
5    age: 34,
6  },
7  {
8    name: 'Carol',
9    gender: 'female',
10    age: 36,
11  },
12  {
13    name: 'Ted',
14    gender: 'male',
15    age: 38,
16  },
17  {
18    name: 'Alice',
19    gender: 'female',
20    age: 40,
21  },
22];
23
24const arr1 = data.filter(d => d.age > 37);
25console.log('arr1', arr1);
26
27const arr2 = data.filter(d => d.gender === 'female');
28console.log('arr2', arr2);
29
30const ageAndGender = d => d.age > 37 && d.gender === 'female';
31
32const arr3 = data.filter(ageAndGender);
33console.log('arr3', arr3);