Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

209
Vistas
Why is includes in JavaScript case sensitive?

I recently stumbled upon a bug caused by .includes() method in javascript. I wanted to return the exact result in respect to case-insensitive but for some reason this does not works

["Ford", "BMW", "Fiat"].includes("bmw");
//returns false
//expected result true

I then fixed my issue with the help of .find() like below:

!!["Ford", "BMW", "Fiat"].find(el => el.toUpperCase() === "bmw".toUpperCase());
//returns true

Can someone help me understand why includes does not work in case-insensitive situations ?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Why would it work case-insensitively? Quoth the MDN:

The includes() method determines whether an array includes a certain value among its entries, returning true or false as appropriate. [...] Note: Technically speaking, includes() uses the sameValueZero algorithm to determine whether the given element is found.

sameValueZero is defined to be Object.is but with +0 and -0 being equal.

That being the case, we can try that out:

> Object.is("bmw", "BMW")
false
> Object.is("bmw", "bmw")
true
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda