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

183
Views
Comprobar si existe una cadena en la matriz

Tengo la siguiente clave StudentMembers[1].active pero necesito verificar si esta clave existe en la siguiente matriz

 const array= ["StudentMembers.Active","StudentMembers.InActive"]

Cómo eliminar el índice [1] de StudentMembers[1].active y verificar si StudentMembers.Active existe en la matriz

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

0

Puede usar expresiones regulares para eliminar todos los corchetes [<any>] de esta manera:

 const key = "StudentMembers[1].active".replace(/\[.*\]/, ''); console.log(key); // Return "StudentMembers.active"

Luego puede usar .find() para verificar si la matriz contiene la clave

 const array= ["StudentMembers.Active","StudentMembers.InActive"]; const hasKey = array.find(item => item.toLowerCase() == key.toLowerCase()) ? true : false; console.log(hasKey); // Return true

Se recomienda encarecidamente usar .toLowerCase() para que coincida con cualquier tipo de casos.

Ejemplo: https://jsfiddle.net/fhkx9v3n/

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!