Creating Array
To create Array we have the following three modes:
- Mode 1: Create an empty Array then Assignment
var khtemple = new Array();khtemple[0] = “Ankgor Wat”;khtemple[1] = “Bayon”;khtemple[2] = “Preah Vihear”;
- Mode 2: Insert Arrayvar khtemple = new Array(“Ankgor Wat”,”Bayon”,”Preah Vihear”);- Mode 3:var khtemple = [“Ankgor Wat”,”Bayon”,”Preah Vihear”];Show Array
example
In the above example, we can show items Array through the index, and if we do not put the index, it will show all the elements of the Array.
Creating Array index string
example
In JavaScript, we can also use String index of the array. In the above example, we see that to each element of the array, we can use Array then use dot and its name index too.






0 comments:
Post a Comment