Siebel eScript Language Reference > Siebel eScript Commands > Array Objects >

The Array Constructor in Siebel eScript

Like other objects, arrays are created using the new operator and the Array constructor function. There are three possible ways to use this function to create an array. The simplest is to call the function with no parameters:

var a = new Array();

This line initializes variable a as an array with no elements. The parentheses are optional when creating a new array if there are no parameters. If you wish to create an array of a predefined number of elements, declare the array using the number of elements as a parameter of the Array() function. The following line creates an array with 31 elements:

var b = new Array(31);

You can pass elements to the Array() function, which creates an array containing the parameters passed. The following example creates an array with six elements. c[0] is set to 5, c[1] is set to 4, and so on up to c[5], which is set to the string "blast off". Note that the first element of the array is c[0], not c[1].

var c = new Array(5, 4, 3, 2, 1, "blast off");

You can also create arrays dynamically. If you refer to a variable with an index in brackets, the variable becomes an array. Arrays created in this manner cannot use the methods and properties described in the next section, so use the Array() constructor function to create arrays.

Siebel eScript Language Reference