Dave's Brain

Browse - Programming Tips - How to I enumerate everything in a javaScript array?

Date: 2010jul19
Language: javaScript
Level: beginner

Q.  How to I enumerate everything in a javaScript array?

A.  If it is NOT an associative array use a for-loop like this:

var i, myelement; var a = [ 'apple', 'ibm', 'microsoft' ]; for (i = 0; i < a.length; i++) { myelement = a[i]; // Do something with myelement }

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.