Rameez Javed

Rameez Javed

  • NA
  • 395
  • 61.6k

Filter Array of Objects from Simple Array Javascript

Feb 26 2020 12:05 AM
Hi, How can i fitler array of objects from simple array. I've two array like below I want to get the array of object whose id is selected in simple array.

  1. Array1 = ["1223", "2344""8775" ];  
  2. Array2 =[{ID: "1223", OrderNo: "8", Name: "Alex", DOB: "02/24/1989"}  
  3. {ID: "2443", OrderNo: "7", Name: "Jordan", DOB: "02/20/2000"}  
  4. {ID: "8775", OrderNo: "6", Name: "Michel", DOB: "11/09/1877"}  
  5. {ID: "2344", OrderNo: "1", Name: "Hallen", DOB: "12/25/1887"}]  
I want to get the resulting array of object including the elements in Array1. dummy resulting array like below.
  1. resultArray =[{ID: "1223", OrderNo: "8", Name: "Alex", DOB: "02/24/1989"}    
  2. {ID: "8775", OrderNo: "6", Name: "Michel", DOB: "11/09/1877"}    
  3. {ID: "2344", OrderNo: "1", Name: "Hallen", DOB: "12/25/1887"}]    
 

Answers (3)