const persons = [
{name:"Shirshak",gender:"male"},
{name:"Amelia",gender:"female"},
{name:"Amand",gender:"male"}
]
//filter return all objects in array
let male = persons.filter(function(person){
return person.gender==='male'
})
console.log(male) //[{name:"Shirshak",gender:"male"},{name:"Amand",gender:"male"}]
//find return first object that match condition
let female = persons.find(function(person){
return person.gender==='female'
})
var data = [
{email: "usera@gmail.com",nama:"User A", Level:"Super Admin"},
{email: "userb@gmail.com",nama:"User B", Level:"Super Admin"},
{email: "userc@gmail.com",nama:"User C", Level:"Standart"},
{email: "userd@gmail.com",nama:"User D", Level:"Standart"},
{email: "usere@gmail.com",nama:"User E", Level:"Admin"},
{email: "userf@gmail.com",nama:"User F", Level:"Standart"}
];
var filter = "Level";
var keyword = "Standart";
var filteredData = data.filter(function(obj) {
return obj[filter] === keyword;
});
console.log(filteredData);
int[] a = {1,2,3,4};
boolean contains = IntStream.of(a).anyMatch(x -> x == 4);