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

129
Views
enumeración de javascript para convertir a la lista y verificar si el valor está presente en esa enumeración

digamos que tengo una enumeración en javascript definida así:

 const myEnum = { A:'a', B:'b', C:'c', D:'d' };

Tengo un personaje y necesito verificar si está presente en la enumeración o no.

Actualmente, estoy haciendo algo como

 if(value !== myEnum.A || value !==myEnum.B || ......) { //FAILURE }

esto es algo así como un problema, ¿cómo lo hago algo como:

 if(value not in myEnum.values){ //FAILURE }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

puedes usar Object.values para verificar esto

 if (!Object.values(myEnum).includes(value)) { // Do what you want here } 

 const myEnum = { A: 'a', B: 'b', C: 'c', D: 'd' }; console.log(Object.values(myEnum).includes('a')); console.log(Object.values(myEnum).includes('v'));

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!