How tp create Arrays using JavaScript??

Q

How tp create Arrays using JavaScript??

✍: Guest

A
<script type="text/javascript">
var days = new Array();
days[0] = "Sunday"
days[1] = "Monday"
days[2] = "Tuesday"
days[3] = "Wednesday"
days[4] = "Thursday"
days[5] = "Friday"
days[6] = "Saturday"
document.write("first day is "+days[0])
</script>

This produces:
first day is Sunday

A more compact way of creating an array is the literal notation:

<script type="text/javascript">
var days = ["Sunday","Monday","Tuesday","Wednesday",
   "Thursday","Friday","Saturday"];
document.write("first day is "+days[0])
</script>

This produces
first day is Sunday

2011-07-12, 2938👍, 0💬