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

77
Views
Javascript array incorrect loop

maybe I'm forgetting something, but I can not loop over and array inside an object.

I have this:

    var myCategory = {
        id: snapshot.id,
        name: category.name,
        order: category.order,
        status: category.status,
        menuOptions:[]
    }

Then I push options

myCategory.menuOptions.push(menuOption);

then I log myCategory and get this:

{id: 'K1VXbeGo3qivFAV61x5P2', name: 'Combos', order: 1, status: 'A', menuOptions: Array(0)}
id: "K1VXbeGo3qivFAV61x5P2"
menuOptions: Array(2)
0: {id: 'LFtAWpu9iKUY0fjXvuji', categoryId: 'K1VXbeGo3qivFAV61x5P2', name: 'Escoge tu salsa', order: 1, OptionsOnItemInCart: undefined, …}
1: {id: 'zp5AwxU04XhhVcGjep1F', categoryId: 'K1VXbeGo3qivFAV61x5P2', name: 'Adicionales', order: 1, OptionsOnItemInCart: undefined, …}
length: 2
[[Prototype]]: Array(0)
name: "Combos"
order: 1
status: "A"
[[Prototype]]: Object

Now I try to loop over myCategory.menuOptions but I can not, this: Array.isArray( category.menuOptions) give me a true,

but when I call category.menuOptions.length return 0.

Any idea? thanks.

about 4 years ago · Juan Pablo Isaza
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!