Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

230
Views
Use lodash to filter array of objects and check if object property value exists in another Array

I am trying to achieve the following task with lodash or pure JS.

I have an Array of Objects which I filter by a given property value


let res = _.filter(array, {obj.property: "somevalue"}

Now I have another Array like so [val1, val2,val3] which I want the filtered array properties to compare with like so.

let res = _.filter(array, {obj.property1: "somevalue", obj.property2: existsInOtherArray}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use a set and the filter method of array like:

const array = [
  {property1: 'somevalue'},
  {property1: 'somevalue', property2: 'val2'}
]

const set = new Set(['val1', 'val2', 'val3'])
const res = array.filter(obj => obj.property1 === 'somevalue'
                                && set.has(obj.property2))

console.log(res)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!