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

219
Visualizações
How can compare and exclude arrays elements with other arrays elements in react native

I need to compare two arrays here is one arrays [...showid] here is another arrays [...swipeeachotheruserId]

in this arrays ,some id will contains this ids will same but not all are same [ 3, 5 , 7 , 10 ,14 ] [ 2, 5, 7, 1, 20, 14 ]

some elements will be same but not all elements same

logic is

showid===swipeeachotheruserId ? will exclude not same id and display here : show id

how can compare and exclude this arrays values

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

const showid = [ 3, 5, 7 , 10 ,14 ];
const swipeeachotheruserId = [ 2, 5, 7, 1, 20, 14 ];

const duplicates = showid.filter(value => swipeeachotheruserId.some(oneElement => oneElement === value));

const mergedArray = [ 
  ...showid, 
  ...swipeeachotheruserId.filter(value => !duplicates.some(oneDuplicate => oneDuplicate === value))
];

const arrayWithoutDuplicate = mergedArray.filter(oneElem => !duplicates.some(value => oneElem === value));

console.log(duplicates);
console.log(mergedArray);
console.log(arrayWithoutDuplicate);

about 4 years ago · Juan Pablo Isaza Relatório

0

if you want to pass the objects which are in both arrays, use this:

return showid.filter(e=>sipeeachotheruserid.includes(e))

if you want to pass the objects which are noth in swipeachotheruserid, then use this:

return showid.filter(e=>!swipeeachotheruserid.includes(e))
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