Arrays:Arrays are Javascript object data capable of story sequence of values. These values are store index location with in array.
Array must be declare before it use.
Syntax:
1. arrayname = new Array(arraylength);
2. arrayname = new Array();
An array element index start with Zero (0) and end with arraylength-1
Example:
<html>
<head>
<title>Arrays</title>
</head>
<body>
<script language="javascript">
var months=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var i=0;
for(i=0;i<12;i++)
{
document.write(months[ i ] + "<br>");
}
</script>
</body>
</html>
OUTPUT
January
February
March
April
May
June
July
August
September
October
November
December
No comments:
Post a Comment