Showing posts with label Array. Show all posts
Showing posts with label Array. Show all posts

Wednesday, May 20, 2009

Enumerate Array or Object

This is how you could enumerate properties of a JavaScript array:

var arr = ['a', 'b', 'c'];

for (var prop in arr)
alert (prop + ":"+ arr[prop]);

Result:
0:a
1:b
2:c