About Array Functions
You use the following operator and an array function to create an array:
new
The following table describes different ways that you can use the array function.
Example Array Function | Description |
---|---|
|
This code initializes the following variable as an array with no elements: a The parentheses are optional. |
|
This code creates an array that includes 31 array elements. If you must create an array that includes a predefined number of array elements, then you can use the number of elements as a argument of the Array function when you declare the array. |
|
This code creates an array that includes six elements:
The first element of the array is c[0]. It is not c[1]. You can write code that passes elements to the Array function, which creates an array that contains the arguments that your code passes. |
You can write code that creates an array dynamically. If you write code that uses an index in brackets to reference a variable, then the variable becomes an array. If you use this technique to create an array, then you cannot use the methods and properties with an associative array.