Help
05-15-2003, 12:35 PM
What is the location where the variable can be used?
|
Click to See Complete Forum and Search --> : Help with Javascript Help 05-15-2003, 12:35 PM What is the location where the variable can be used? Jona 05-15-2003, 12:39 PM var myArray = new Array("one","two","three","four","five"); alert(myArray[0]); // alerts "one" for(i=0;i<myArray.length;i++){ alert(myArray[i]); //alerts one, then alerts, two, then alerts, three, and so on... } Charles 05-15-2003, 01:13 PM And <script type="text/javascript"> <!-- array = ['fee', 'fie', 'foe', 'fum']; alert (array) // --> </script> Gives you fee,fie,foe,fum. Jona 05-15-2003, 01:18 PM Yes, there are many ways to make an array: var array = new Array(3); array[0] = "value0"; array[1] = "value1"; array[2] = "value2"; array[3] = "value3"; var array = new Array("value0","value1","value2","value3"); var array = ["value0", "value1", "value2", "value3"]; var str = "value0, value1, value2, value3"; for(i=0;i<4;i++){ var array = str.split(",")[i]; } Note: the third method shouldn't be used as often as the above. ;) webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |