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

82
Views
Array is returning undefined even though it has variables stored

When I try "console.log" the whole array it shows, but when I try array.length or array[0] it is returning undefined and an empty array. I am pushing strings into an array from a Json file. In the screen shot below is the difference when logging a normal string array and my array which i think is the reason this is happening but I cant figure out how to fix it enter image description here

Here is some of the thing that is not making sense for me

console.log(posts2); // returns 0: "Day #50" 1: "Ramadan Kareem" 2: "Freedom" 3: "Elife Unlimited" 4: "Wasel Gifts" length: 5

console.log(posts2.slice(0,2)); // returns empty array

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!