Wb10
Wb10

Reputation: 89

Unable to get the length of an array inside an array

I want to get the length of the first array in an array (should return 2010), but I can't seem to do so with .length. The picture attached is a snapshot of the console when I run:

console.log(marker)

enter image description here

When I try to run the following, it returns TypeError: Cannot read property 'length' of undefined.

console.log(marker[0].length)
//TypeError: Cannot read property 'length' of undefined
console.log(marker.length)
//returns 3

Can someone point me in the right direction? Can't seem to understand what's wrong.

Upvotes: 1

Views: 126

Answers (1)

AGoranov
AGoranov

Reputation: 2244

Normally the issue with such types of unexpected results is the *blueish) small question mark on the right side. It means that the result was evaluated after your code finished executing, aka async issue.

I would suggest that you see in your code where the async call appears and await it.

Upvotes: 1

Related Questions