June 13, 2009

0 Modify Values in Existing Arrays


To modify a value in an existing array, just add a new value to the array with a specified index number:

mycars [0] = "Opel"

Now the following code line:

document.write (mycars [ 0 ] )

wll result in the following output:

Opel

Example

For - In statement

<html>

<body>

<script type="text/javascript">

var x

var mycars = new Array()

mycars [0] = "Saab"
mycars [1] = "Volvo"
mycars [2] = "BMW"

for (x in mycars)

{

document.write(mycars[x] + "<br />")

}

</script
</body>
</html>



0 comments:

Post a Comment

Blogger Themes

 
Powered by Blogger