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

354
Vistas
Difference between in and includes in NodeJS

I was very surprised to find out that:

> 'a' in ['a', 'b']
false
> ['a','b'].includes('a')
true

What does each command perform in NodeJS?

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

0

This is not node specific but ECMA (JS) specific.

in Operator

Checks the existence of key in the collection (similar to hasOwnPropertybut also check inherited keys in prototype chain)

includes method of Array (introduced in ES6)

Checks the existence of value in the collection

about 4 years ago · Juan Pablo Isaza Denunciar

0

Array.includes() checks for the existence of a certain value in an array, while the in operator checks for the existence of a key in an object (or an index in the case of arrays like you're describing).

console.log('a' in ['a', 'b']); // false, no such key
console.log(0 in ['a', 'b']); // true, 0 is a key that exists
console.log(1 in ['a', 'b']); // true, 1 is a key that exists
console.log(2 in ['a', 'b']); // false, 2 is a key that doesn't exists

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