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

223
Views
¿Cómo se pueden comparar y excluir elementos de matrices con otros elementos de matrices en reaccionar nativo?

Necesito comparar dos matrices aquí hay una matriz [... showid] aquí hay otra matriz [... swipeeachotheruserId]

en estas matrices, algunos ID contendrán estos ID iguales pero no todos son iguales [3, 5, 7, 10, 14] [2, 5, 7, 1, 20, 14]

algunos elementos serán iguales pero no todos los elementos iguales

la lógica es

showid===deslizar otro ID de usuario? no excluirá la misma identificación y se mostrará aquí: mostrar identificación

¿Cómo se pueden comparar y excluir los valores de esta matriz?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

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 Report

0

si desea pasar los objetos que están en ambas matrices, use esto:

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

si desea pasar los objetos que no están en swipeachotheruserid, use esto:

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