Here you can find a number of examples on Java Script.Please find the various kinds of examples listed on the right side of this site. If you don't find anything on Java Script then please write to us or leave a commnet. We are pleased to help and find the solution of your problem.

Javascript: Create Array



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>

&ltscript 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 ] + "&ltbr>");
}
</script>

</body>
</html>



OUTPUT

January
February
March
April
May
June
July
August
September
October
November
December

No comments:

Post a Comment

Google