<!-- JavaScript:Arrays code snippet 2. -->
<!-- Create an array using literal notation and assignment of
literal values, changing element values and write values to the page -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- Code source: http://www.justfigures.co.uk/ -->
<!-- A resource for web developers using XHTML, CSS, JavaScript, PHP -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>View code snippet page</title>
</head>
<body>
<script language="JavaScript" type="text/javascript">
<!--
/* Create an array using literal notation and assignment of
literal values: in this case numbers */
// note the use of the square brackets []
var myArray = [4,8,6,9,3];
/* access a specific element by its index position and write to the page */
/* note that the indexing starts from 0 */
document.write("Value of element at index position 0 is: "+myArray[0]+"<br />");
/* change the element at index position 0 */
myArray[0]=(myArray[0]+6);
document.write("Add 6 and element value is now: "+myArray[0]);
// -->
</script>
</body>
</html>