How to create arrays in JavaScript?

Submitted by: Administrator
We can declare an array like this <br>var scripts = new Array() <br>We can add elements to this array like this <br> <br>scripts[0] = " PHP" <br>scripts[1] = " ASP" <br>scripts[2] = " JavaScript" <br>scripts[3] = " HTML" <br> <br>Now our array scripts have 4 elements inside it and we can print or access them by using their index number. Note that index number starts from 0. To get the third element of the array we have to use the index number 2. Here is the way to get the third element of an array. <br>document.write(scripts[2]) <br>We also can create an array like this <br>var no_array = new Array(21, 22, 23, 24, 25) <br>
Submitted by: Administrator

Read Online JavaScript Job Interview Questions And Answers