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

178
Views
Operador de igualdad con múltiples valores en JavaScript

¿Hay una manera simple de comparar múltiples valores con un solo valor en Javascript?

Me gusta, en lugar de escribir:

 if (k != 2 && k != 3 && k!= 7 && k!12)

Escribiendo algo como:

 if (k != {2,3,7,12})
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede utilizar includes en lugar de comparaciones de igualdad múltiple.

 if (![2,3,7,12].includes(k))

Eso es álgebra booleana:

 if (k != 2 && k != 3 && k!= 7 && k != 12)

es equivalente a

 if (!(k == 2 || k == 3 || k == 7 || k == 12))

y eso es equivalente a

 if (![2,3,7,12].includes(k))
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!