Iterating Through a Sparse Array
<HTML> <HEAD> <TITLE>Iterating Through a Sparse Array</TITLE> </HEAD> <BODY> <SCRIPT> var myArray = new Array(4); myArray[0] = "d"; myArray[1] = "c"; myArray[2] = "s"; myArray[3] = "d"; myArray[6] = "c"; myArray[1] = undefined; for (var i = 0; i < myArray.length; i++){ if (myArray[i] != undefined) document.write("myArray[" + i + "] = " + myArray[i] + "<br>"); } </SCRIPT> </BODY> </HTML>