Arrays are simple ways to store various data, it is possible to allocate them in a single memory space various data. In Javascript, it is used from the array object and has three types of calls, as example below:

<SCRIPT LANGUAGE=”JavaScript” TYPE=”text/javascript”>
//simple call without scaling
Vet1 = new Array();

//simple call without scaling
Vet2 = new Array(2);

//simple call with values
Vet3 = new Array (“Texto 1″, “Texto 2″);


The type of logic to be implemented is that which defines the call type to be used.

Just as in other programming languages​​, an array has a first position accessed from the zero position. So, if you want to access data from an array is important to take this item into consideration, check out:

<SCRIPT LANGUAGE=”JavaScript” TYPE=”text/javascript”>
var Vet = new Array (“Texto 1″, “Texto 2″);
document.write(“First position: ” + Vet[0]);
document.write(“</br>Second position: ” + Vet[1]);

In the above example used the method call passing the values ​​of the array and then written in the following respective amounts screen informing the positions according to the description in the row.

The array object still has some important attributes, one is lenght that informs the current size of the array and can be used as a parameter to sweep all positions in the code below is an example of practical use:

<SCRIPT LANGUAGE=”JavaScript” TYPE=”text/javascript”>
var Vet = new Array (“1”, “2”, “3”);
document.write (“<p>This array has ” + Vet.length + ” numbers. These numbers are:</p>”);
document.write (“<ul>”);
for (index=0;
index < Vet .length;
document.write (“<li>” + Vet[index] + “</li>”)
document.write (“</ul>”);

The use of arrays is very common, so it is important that you understand your logic utilization. Many everyday problems of a programmer can be solved with a simple array and learn to manipulate them is essential.


Test this and other code in Javascript in Scriptcase and also learn about other resources that our tool provides. Download the free version now and learn how to have more results with their web applications.

You might also like…

Scriptcase & Web Services

This time I will explain how to work with web services inside the Scriptcase, directly with PHP and...

More updates in 9.4 version

Recently version 9.4 was released bringing a new design concept to the generated applications of Sc...

Taking a look at version 9.4

Scriptcase released its version 9.4, and this one brings many interesting news, specially regarding...

Comment this post

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at Learn more about our Privacy Police.