JavaScript Tutorial

adplus-dvertising
Array In JavaScript
Previous Home Next

An array is a variable that can store many variables.JavaScript has variables and properties associated with array Creating an array is slightly different from creating a normal variable.

The Array parameter is also used in list of strings or integers.

Syntax :

var vehicls = new Array( "car", "bike", "train" );

Example :

<html>
<head>
<script>
var myArray = new Array();

myArray[0] = "Football"; 
myArray[1] = "Baseball";
myArray[2] = "Cricket";

document.write(myArray[0]+"</br>" + myArray[1]+"</br>" + myArray[2]);
</script>
</html>
</head>

Output :

Football
Baseball
Cricket
Previous Home Next