JavaScript Arrays

Domain Hosting image
Web Hosting
Dedicated server
ssl certificate
Web Design image
Email
Array is a special type of JavaScript object. Arrays are used for storing data in a contiguous manner.For example if you want to store the names of courses taught at Pentasoft you can use arrays. The syntax for declaring an Array is:

course = new Array(3).

To assign values to an array the following statements can be used:

course[O] = "E commerce"
course[1] = "AIPP"
course[2] = "VisaBanking"

The following example illustrates how to declare an array and to write array elements to the docu ment.

<html>
<head>
<title>
Declaring Arrays</title>
<script language="JavaScript">
<!--
course=new array(3)
course[0]="E-Commerce"

course[1]="AIPP"

course[2]="VisaBanking"
document.write("Courses taught at Pentasoft"+"<br>")
document.writeln("First Element:"+course[0]+"<br>")
document.write("Second Element:"+course[1]"+"<br>")
document.write("Third Element:"+course[2]"+"<br>")
//-->
</script>
</head>
</html>



Domain Name Search

www.


Copyright (C) 2007. Web Domain design hosting. All rights reserved.