0

I've typed the following code ​ ​ console.log(balanrrey); console.log(balanrrey[0]); ​

then this shows on the console:

Array []
0: 10
​1: 40.28
​2: 20.14
​3: 24.34
​length: 4

undefined

Any idea on why this might be happening? I swear I spent 2 hours trying to find an answer.

Lasfito
  • 1
  • 1
  • Is the array being filled in by asynchronous code? – Barmar May 14 '21 at 00:56
  • are you sure the key is `0` and not something else? e.g. associative arrays – Michael Mano May 14 '21 at 00:57
  • Notice that the console.log shows `[]`. At the time you logged it, the array was empty. It was filled in asynchronously, so when you expanded it you saw the contents added later. – Barmar May 14 '21 at 00:58
  • 1
    Give more code and information about your problem. Are you typing the code in the console? Where are you adding values / creating `balanrrey`? – bub May 14 '21 at 00:58

0 Answers0