0

See a screenshot of my returned data i did a console.log on which i need to do a for each on.

array

i have been trying things like this to no avail...?

for (var point in arrayLatLngPoints)
{
    addMarkers(point.timestamp, point.lat, point.lng, point.timestamp, strUserName, pathColour);
}
1
  • What's assigned to point inside the loop? Commented Jul 2, 2012 at 10:27

1 Answer 1

2

Don't use for..in to loop an array, use normal for loop instead.

for (var i = 0; i < arrayLatLngPoints.length; i++)
{
    var point = arrayLatLngPoints[i];
    addMarkers(point.timestamp, point.lat, point.lng, point.timestamp, strUserName, pathColour);
}
Sign up to request clarification or add additional context in comments.

2 Comments

I think a brief explanation as to why they shouldn't use for..in to iterate over an array would make this answer a lot better.
Good info in developer.mozilla.org/en/JavaScript/Reference/Statements/… for why not to use for..in

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.