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

191
Views
¿Acceder a la matriz actual del índice del objeto con objectArray.length no funciona?

var objArray = []; var objeto = {};

Estoy definiendo cada índice de la matriz agregando:

 objArray[objArray.length] = object;

Y puedo acceder a la longitud de objArray haciendo

 objArray.length;

Sin embargo, si trato de hacer

 objArray[objArray.length],

me da indefinido.

¿Por qué es esto?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Porque la indexación de matrices comienza con 0, pero cuando hay un elemento en una matriz, su índice es 0 y la longitud de la matriz es 1. Pruebe objArray[objArray.length -1] y funcionará.

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!