Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

238
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda