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

267
Vistas
Accessing a boolean property of an object in javascript always returns false?

I'm losing my mind. I have an array of objects called allAvailabilities

console.log(allAvailabilities[0]);

results in a object with various properties, one of which is:

...
isTrainee: true
...

but

console.log(allAvailabilities[0]['isTrainee']);
console.log(allAvailabilities[0].isTrainee);

results in

false
false

I'm not understanding what is preventing me from accessing the actual isTrainee value of the object property:

console.log(typeof(allAvailabilities[0]['isTrainee']));
console.log(typeof(allAvailabilities[0].isTrainee));
console.log(allAvailabilities[0]['isTrainee'].toString());
console.log(allAvailabilities[0].isTrainee.toString());

results in:

boolean
boolean
false
false

How is this possible? Am I overlooking a fundamental piece of Javascript syntax? Does this have to do with the Boolean class as described here: Why does !new Boolean(false) equals false in JavaScript?

enter image description here

The snippet works fine, what does this mean?

var allAvailabilities = [{_id: '605a5dd76f007e84f28e35fd', begin: '2021-04-03T18:00:00.000Z', end: '2021-04-03T20:30:00.000Z', season: 'regular', hostModel: 'users', isTrainee: true, season: "regular"}];


            console.log(allAvailabilities[0]);
            console.log(typeof(allAvailabilities[0]['isTrainee']));
            console.log(typeof(allAvailabilities[0].isTrainee));
            console.log(allAvailabilities[0]['isTrainee'].toString());
            console.log(allAvailabilities[0].isTrainee.toString());

How can this be? enter image description here

The original allAvailabilities array comes from an API, and each object in the array is modified to have the isTrainee property like so, immediately before calling the code I am having problems with:

enter image description here

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

0

I think it is because there is a promise asynchronous modification of isTrainee in the map. I think changing the map to for may solve the problem. For is a synchronous function rather than asynchronous.

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