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

277
Vistas
How does the in operator work with sets in JavaScript?

Why does the following code:

'%' in new Set('%');

return false?

And is the in operator faster on a set than on an array?

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

0

The in operator returns true if the specified property is in the specified object or its prototype chain.

It does not check if something belongs to a set. You should use Set.prototype.has for that.

const obj = { someKey: 'someValue' };
'someKey' in obj; // true
'someOtherKey' in obj; // false

const set = new Set([1,2,3]);
set.has(1); // true
set.has(4); // false

Regarding performance, please refer to this question

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