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

266
Views
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 answers
Answer question

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 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!