Dave's Brain

Browse - programming tips - javascript enumerate everything in an 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
	}

What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2010, 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.