“Filter Array Objek Filter” Kode Jawaban

cara memfilter array objek di javascript

let arr=[{id:1,title:'A', status:true}, {id:3,title:'B',status:true}, {id:2, title:'xys', status:true}];
//find where title=B
let x = arr.filter((a)=>{if(a.title=='B'){return a}});
console.log(x)//[{id:3,title:'B',status:true}]
Handsome Hedgehog

JavaScript filter array objek

let people = [
  { name: "Steve", age: 27, country: "America" },
  { name: "Jacob", age: 24, country: "America" }
];

let filteredPeople = people.filter(function (currentElement) {
  // the current value is an object, so you can check on its properties
  return currentElement.country === "America" && currentElement.age < 25;
});

console.log(filteredPeople);
// [{ name: "Jacob", age: 24, country: "America" }]
Wicked Wryneck

Array Filter JavaScript Objek dengan Array

var arr = [1,2,3,4],
    brr = [2,4],
    res = arr.filter(f => !brr.includes(f));
console.log(res);
Powerful Penguin

Filter array objek dengan array objek

const myArray = [{ userid: "100", projectid: "10", rowid: "0" }, { userid: "101", projectid: "11", rowid: "1"}, { userid: "102", projectid: "12", rowid: "2" }, { userid: "103", projectid: "13", rowid: "3" }, { userid: "101", projectid: "10", rowid: "4" }];
const myFilter = [{ userid: "101", projectid: "11" }, { userid: "102", projectid: "12" }, { userid: "103",  projectid: "11"}];

const myArrayFiltered = myArray.filter((el) => {
  return myFilter.some((f) => {
    return f.userid === el.userid && f.projectid === el.projectid;
  });
});

console.log(myArrayFiltered);
sevspo

Filter Array Objek Filter

objects.filter((value, index, self) => {
  return self.findIndex(v => v.actor.name === value.actor.name) === index;
})
Nervous Narwhal

Jawaban yang mirip dengan “Filter Array Objek Filter”

Pertanyaan yang mirip dengan “Filter Array Objek Filter”

Lebih banyak jawaban terkait untuk “Filter Array Objek Filter” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya