6

enter image description here Can anyone help me understand why the Array is showing as being empty, when it also shows that it has data/ values ?

I am not able to access the data. See picture for reference.

Rajaprabhu Aravindasamy
  • 66,513
  • 17
  • 101
  • 130
  • 2
    @Teemu He will find the reason. How others will find it? You explain it here. – Rajaprabhu Aravindasamy Feb 25 '16 at 20:03
  • 1
    You can tell us, what the tooltip of that info mark says exactly. I don't have Chrome at hands right now, but the idea is, that the line with info mark is populated at different time than the property list. The basic reason is, that `console.log` is asynchronous. Why you can't access data is hard to say without seeing the code. – Teemu Feb 25 '16 at 20:12
  • 2
    A speculative guess would be, that you're logging a value from asynchronously populated data too early. If that's the case, see http://stackoverflow.com/questions/14220321/how-to-return-the-response-from-an-asynchronous-call/14220323#14220323 – Teemu Feb 25 '16 at 20:24

1 Answers1

13

Objects logged in the Javascript console are "live", so expanding them shows the current contents of the object. The first line shows that the outputList was empty when you first called console.log(). But something was added to the array later, and when you expanded the object by clicking on the disclosure triangle, you see the updated value.

Barmar
  • 741,623
  • 53
  • 500
  • 612