Create Array in Javascript (3 Ways)

Chikul
Posted by Chikul under JavaScript category on | Views : 1894
Way 1:
<script>
Fruits = new Array("Orange", "Apple", "Banana", "Grapes", "Mango");
</script>

Way 2:
<script>
Fruits = new Array(5);
Fruits[0] = "Orange"
Fruits[1] = "Apple"
Fruits[2] = "Banana"
Fruits[3] = "Grapes"
Fruits[4] = "Mango"
</script>

Way 3:
<script>
Fruits = ["Orange", "Apple", "Banana", "Grapes", "Mango"];
</script>

Comments or Responses

Login to post response