0

I'm having this weird issue where I have an array returned from a function:

let result = new Array();
result.push(compressedFile)
return result

Then I simply try to console.log the array's length and it's first value:

files = ****result from other function****
console.log(files)
console.log(files.length)
console.log(files[0])
console.log(files['0'])

And here's what's returned in the console:

console screenshot

The console clearly shows that the files variable holds values. What am I missing?

Mr. Polywhirl
  • 42,981
  • 12
  • 84
  • 132
Rens
  • 489
  • 5
  • 11
  • 1
    Does this answer your question? [JavaScript Array.length returning 0](https://stackoverflow.com/questions/36307213/javascript-array-length-returning-0) – stijnb1234 Oct 02 '20 at 12:43
  • It's not actually an array. It is an object. Where does `files` come from? – Mr. Polywhirl Oct 02 '20 at 12:54
  • `files = ****result from other function****` - I bet there's asynchrony involved in this "other function" – Jaromanda X Oct 02 '20 at 13:18
  • Okay, so apparently I'm logging the array while it's empty and the inspecter is showing the live state of the array, i.e. after it was filled. @JaromandaX – Rens Oct 02 '20 at 17:01

0 Answers0