25 Dec 2013
Array in JavaScript
Array is use to store multiple values in a one variable.
-
Example 1:
<script>
var a = new Array();
a[0] = 2;
alert(a[0]);
</script>
var a = new Array();
a[0] = 2;
alert(a[0]);
</script>
Example 2:
<script>
var b = new Array(78,4,5,3,5,7);
for(i=0; i < b.length; i++) { alert(b[i]); } </script>
var b = new Array(78,4,5,3,5,7);
for(i=0; i < b.length; i++) { alert(b[i]); } </script>
Example 3:
<script type=”text/javascript”>
var ar = new Array(“Ram”,”Deep”,”Ravi”,”Mohit”);
for (i=0; i
var ar = new Array(“Ram”,”Deep”,”Ravi”,”Mohit”);
for (i=0; i