The syntax of creating array directly is given below:
var arrayname=new Array();
Here, new keyword is used to create instance of array.
<!DOCTYPE html>
<html>
<head>
<title>JavaScript</title>
<script>
var ary = new Array();
ary[0] = 10;
ary[1] = 'Harry';
ary[2] = true;
document.write("<ul>");
for(var a = 0; a < 3; a++){
document.write("<li>" + ary[a] + "</li>");
}
document.write("</ul>");
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>JavaScript</title>
<script>
var ary = new Array(3);
for(var g = 0; g < 3; g++){
ary[g] = prompt("Enter the Value : ");
}
document.write("<ul>");
for(var a = 0; a < 3; a++){
document.write("<li>" + ary[a] + "</li>");
}
document.write("</ul>");
</script>
</head>
<body>
</body>
</html>