ArrayUtil - Global
-
- UpdatedJan 30, 2025
- 5 minutes to read
- Yokohama
- API reference
The ArrayUtil script include provides methods for working with JavaScript arrays.
These methods are available to any server-side script.
ArrayUtil - concat(Array parent, Array child)
Merge two arrays.
Name | Type | Description |
---|---|---|
parent | Array | An array to merge |
child | Array | An array to merge |
Type | Description |
---|---|
Array | An array of elements from both input arrays. Duplicates are not removed. |
Example
Output: concat a1, a2: a,b,c,c,d,e
ArrayUtil - contains(Array array, Object element)
Searches the array for the specified element. Returns true if the element exists in the array, otherwise returns false.
Name | Type | Description |
---|---|---|
array | Array | Array to search. |
element | Object | Element to search for. |
Type | Description |
---|---|
Boolean | Flag indicating whether the element was found in the array. Possible
values:
|
Example
ArrayUtil - convertArray(Object a)
Converts a Java object to an array.
Name | Type | Description |
---|---|---|
a | Object | Object to convert. |
Type | Description |
---|---|
Array | Array created from the object. |
Example
This example converts a Java object to an array.
Output:
ArrayUtil - diff(Array a, Array b)
Finds the differences between two or more arrays.
Any number of arrays can be provided as parameters.
Name | Type | Description |
---|---|---|
a | Array | An array |
b | Array | An array |
Type | Description |
---|---|
Array | Returns an array of items from array a that were not found in either array b or c, or other input arrays. Duplicates are removed from the result. |
Example
Output: a,b
ArrayUtil - ensureArray(Object object)
Returns an array from the specified object.
Name | Type | Description |
---|---|---|
object | Object | Object from which to create an array. |
Type | Description |
---|---|
Array | Array created from the object. |
Example
The following example shows how to create an array from an object and display created array.
Example
The following example shows how to create an array from an object and display the contents of the array.
ArrayUtil - indexOf(Array array, Object element)
Searches the array for the element. Returns the element index or -1 if not found.
Name | Type | Description |
---|---|---|
array | Array | Array to search. |
element | Object | Element to search for. |
Type | Description |
---|---|
Number | Position of the element in the array, or -1 if the element is not found. |
Example
ArrayUtil - indexOf(Array array, Object element, Number startIndex)
Searches the array for the element starting at the specified index. Returns the element index or -1 if not found.
Name | Type | Description |
---|---|---|
array | Array | Array to search. |
element | Object | Element to search for. |
startIndex | Number | Index to start searching from. |
Type | Description |
---|---|
Number | Position of the element in the array, or -1 if the element is not found. |
Example
ArrayUtil - intersect(Array a, Array b)
Finds the elements present in all arrays.
Any number of arrays can be provided as parameters.
Name | Type | Description |
---|---|---|
a | Array | An array |
b | Array | An array |
Type | Description |
---|---|
Array | An array of elements from array a that were found in all of the other input arrays. Duplicates are removed. |
Example
Output: c
ArrayUtil - union(Array a, Array b)
Merge two or more arrays.
Any number of arrays can be provided as parameters.
Name | Type | Description |
---|---|---|
a | Array | An array |
b | Array | An array |
Type | Description |
---|---|
Array | An array of items from all the input arrays. Duplicates are removed. |
Example
Output: a,b,c,d,e
ArrayUtil - unique(Array a)
Removes duplicate items from an array.
Name | Type | Description |
---|---|---|
a | Array | The array to check for duplicate elements. |
Type | Description |
---|---|
Array | An array of unique items from the input array. |
Example
Output: a,c,b
On this page
- ArrayUtil - concat(Array parent, Array child)
- ArrayUtil - contains(Array array, Object element)
- ArrayUtil - convertArray(Object a)
- ArrayUtil - diff(Array a, Array b)
- ArrayUtil - ensureArray(Object object)
- ArrayUtil - indexOf(Array array, Object element)
- ArrayUtil - indexOf(Array array, Object element, Number startIndex)
- ArrayUtil - intersect(Array a, Array b)
- ArrayUtil - union(Array a, Array b)
- ArrayUtil - unique(Array a)