# Array

## Overview

The javascript Array implementation.\
It is a collection of items kept by index, providing typical array API. The index is a integer (>= 0) or a string representing such an integer.

For more information see: [Array (MDN)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array).

## Properties Summarized

| Type                                                                         | Name                | Summary                      |
| ---------------------------------------------------------------------------- | ------------------- | ---------------------------- |
| [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) | [\[index\]](#index) | Get an element by index.     |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) | [length](#length)   | Get the length of the array. |

## Methods Summarized

| Type                                                                             | Name                                                                                                 | Summary                                                                                                                                                                             |
| -------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [at(index)](#at-index)                                                                               | Takes an integer value and returns the item at that index, allowing for positive and negative integers.                                                                             |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [concat(value1)](#concat-value1)                                                                     | Returns a new array comprised of this array joined with other array(s) and/or value(s).                                                                                             |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [concat(value1, value2)](#concat-value1-value2)                                                      | Returns a new array comprised of this array joined with other array(s) and/or value(s).                                                                                             |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [concat(value1, value2, valueN)](#concat-value1-value2-valuen)                                       | Returns a new array comprised of this array joined with other array(s) and/or value(s).                                                                                             |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [copyWithin(target)](#copywithin-target)                                                             | Shallow copies part of an array to another location in the same array and returns it without modifying its length                                                                   |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [copyWithin(target, start)](#copywithin-target-start)                                                | Shallow copies part of an array to another location in the same array and returns it without modifying its length                                                                   |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [copyWithin(target, start, end)](#copywithin-target-start-end)                                       | Shallow copies part of an array to another location in the same array and returns it without modifying its length                                                                   |
| [Iterator](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/iterator) | [entries()](#entries)                                                                                | The entries() method of Array instances returns a new array iterator object that contains the key/value pairs for each index in the array.                                          |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)   | [every(callback)](#every-callback)                                                                   | Runs a function on items in the array while that function is returning true.                                                                                                        |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)   | [every(callback, thisObject)](#every-callback-thisobject)                                            | Runs a function on items in the array while that function is returning true.                                                                                                        |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [fill(value)](#fill-value)                                                                           | Changes all elements in an array to a static value, from a start index (default 0) to an end index (default array.                                                                  |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [fill(value, start)](#fill-value-start)                                                              | Changes all elements in an array to a static value, from a start index (default 0) to an end index (default array.                                                                  |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [fill(value, start, end)](#fill-value-start-end)                                                     | Changes all elements in an array to a static value, from a start index (default 0) to an end index (default array.                                                                  |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [filter(callback)](#filter-callback)                                                                 | Runs a function on every item in the array and returns an array of all items for which the function returns true.                                                                   |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [filter(callback, thisObject)](#filter-callback-thisobject)                                          | Runs a function on every item in the array and returns an array of all items for which the function returns true.                                                                   |
| [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object)     | [find(callback)](#find-callback)                                                                     | Returns the value of the first element in the provided array that satisfies the provided testing function.                                                                          |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)     | [findIndex(callback)](#findindex-callback)                                                           | Returns the index of the first element in the provided array which satisfies the provided testing function.                                                                         |
| [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object)     | [findLast(callback)](#findlast-callback)                                                             | Iterates the array in reverse order and returns the value of the first element that satisfies the provided testing function.                                                        |
| [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object)     | [findLastIndex(callback)](#findlastindex-callback)                                                   | Iterates the array in reverse order and returns the index of the first element that satisfies the provided testing function.                                                        |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [flat()](#flat)                                                                                      | The flat() method of Array instances creates a new array with all sub-array elements concatenated into it recursively up to the specified depth.                                    |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [flat(depth)](#flat-depth)                                                                           | The flat() method of Array instances creates a new array with all sub-array elements concatenated into it recursively up to the specified depth.                                    |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)   | [flatMap(callback)](#flatmap-callback)                                                               | The flatMap() method of Array instances returns a new array formed by applying a given callback function to each element of the array, and then flattening the result by one level. |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)   | [flatMap(callback, thisObject)](#flatmap-callback-thisobject)                                        | The flatMap() method of Array instances returns a new array formed by applying a given callback function to each element of the array, and then flattening the result by one level. |
| void                                                                             | [forEach(callback)](#foreach-callback)                                                               | Runs a function (callback) on every item in the array.                                                                                                                              |
| void                                                                             | [forEach(callback, thisObject)](#foreach-callback-thisobject)                                        | Runs a function (callback) on every item in the array.                                                                                                                              |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [from(value)](#from-value)                                                                           | Creates a new, shallow-copied Array instance from an iterable or array-like object.                                                                                                 |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [from(value, mapFunction, thisObject)](#from-value-mapfunction-thisobject)                           | Creates a new, shallow-copied Array instance from an iterable or array-like object.                                                                                                 |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)   | [includes(searchElement)](#includes-searchelement)                                                   | Determines whether an array includes a certain value among its entries, returning true or false as appropriate.                                                                     |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)   | [includes(searchElement, start)](#includes-searchelement-start)                                      | Determines whether an array includes a certain value among its entries, returning true or false as appropriate.                                                                     |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)     | [indexOf(searchElement)](#indexof-searchelement)                                                     | Returns the first index at which a given element can be found in the array, or -1 if it is not present.                                                                             |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)     | [indexOf(searchElement, fromIndex)](#indexof-searchelement-fromindex)                                | Returns the first index at which a given element can be found in the array, or -1 if it is not present.                                                                             |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)   | [isArray(obj)](#isarray-obj)                                                                         | Checks whether an object is an array or not.                                                                                                                                        |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)     | [join(delimiter)](#join-delimiter)                                                                   | Puts all elements in the array into a string, separating each element with the specified delimiter                                                                                  |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [js\_with(index, value)](#js_with-index-value)                                                       | It is the copying version of using the bracket notation to change the value of a given index.                                                                                       |
| [Iterator](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/iterator) | [keys()](#keys)                                                                                      | The keys() method of Array instances returns a new array iterator object that contains the keys for each index in the array.                                                        |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)     | [lastIndexOf(searchElement)](#lastindexof-searchelement)                                             | Returns the last index at which a given element can be found in the array, or -1 if it is not present.                                                                              |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)     | [lastIndexOf(searchElement, fromIndex)](#lastindexof-searchelement-fromindex)                        | Returns the last index at which a given element can be found in the array, or -1 if it is not present.                                                                              |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [map(callback)](#map-callback)                                                                       | Runs a function on every item in the array and returns the results in an array.                                                                                                     |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [map(callback, thisObject)](#map-callback-thisobject)                                                | Runs a function on every item in the array and returns the results in an array.                                                                                                     |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [of(value)](#of-value)                                                                               | Ccreates a new Array instance from a variable number of arguments.                                                                                                                  |
| [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object)     | [pop()](#pop)                                                                                        | Pops the last string off the array and returns it.                                                                                                                                  |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)     | [push(value1)](#push-value1)                                                                         | Mutates an array by appending the given elements and returning the new length of the array.                                                                                         |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)     | [push(value1, value2)](#push-value1-value2)                                                          | Mutates an array by appending the given elements and returning the new length of the array.                                                                                         |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)     | [push(value1, value2, valueN)](#push-value1-value2-valuen)                                           | Mutates an array by appending the given elements and returning the new length of the array.                                                                                         |
| [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object)     | [reduce(f, initialValue)](#reduce-f-initialvalue)                                                    | Reduces the array to a single value by executing a provided function for each value of the array (from left-to-right).                                                              |
| [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object)     | [reduceRight(f)](#reduceright-f)                                                                     | The reduceRight() method of Array instances applies a function against an accumulator and each value of the array (from right-to-left) to reduce it to a single value.              |
| [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object)     | [reduceRight(f, initialValue)](#reduceright-f-initialvalue)                                          | The reduceRight() method of Array instances applies a function against an accumulator and each value of the array (from right-to-left) to reduce it to a single value.              |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [reverse()](#reverse)                                                                                | Puts array elements in reverse order.                                                                                                                                               |
| [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object)     | [shift()](#shift)                                                                                    | Decreases array element size by one by shifting the first element off the array and returning it.                                                                                   |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [slice(begin)](#slice-begin)                                                                         | The slice method creates a new array from a selected section of an array.                                                                                                           |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [slice(begin, end)](#slice-begin-end)                                                                | The slice method creates a new array from a selected section of an array.                                                                                                           |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)   | [some(callback)](#some-callback)                                                                     | Runs a function on items in the array while that function returns false.                                                                                                            |
| [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)   | [some(callback, thisObject)](#some-callback-thisobject)                                              | Runs a function on items in the array while that function returns false.                                                                                                            |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [sort()](#sort)                                                                                      | Sorts the array elements in dictionary order or using a compare function passed to the method.                                                                                      |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [sort(function)](#sort-function)                                                                     | Sorts the array elements in dictionary order or using a compare function passed to the method.                                                                                      |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [splice(arrayIndex, length)](#splice-arrayindex-length)                                              | It is used to take elements out of an array and replace them with those specified.                                                                                                  |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [splice(arrayIndex, length, value1)](#splice-arrayindex-length-value1)                               | It is used to take elements out of an array and replace them with those specified.                                                                                                  |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [splice(arrayIndex, length, value1, value2)](#splice-arrayindex-length-value1-value2)                | It is used to take elements out of an array and replace them with those specified.                                                                                                  |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [splice(arrayIndex, length, value1, value2, valueN)](#splice-arrayindex-length-value1-value2-valuen) | It is used to take elements out of an array and replace them with those specified.                                                                                                  |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [toReversed()](#toreversed)                                                                          | The toReversed() method transposes the elements of the calling array object in reverse order and returns a new array.                                                               |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [toSorted()](#tosorted)                                                                              | It is the copying version of the sort() method.                                                                                                                                     |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [toSorted(comparator)](#tosorted-comparator)                                                         | It is the copying version of the sort() method.                                                                                                                                     |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [toSpliced(start)](#tospliced-start)                                                                 | It is the copying version of the splice() method.                                                                                                                                   |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [toSpliced(start, deleteCount)](#tospliced-start-deletecount)                                        | It is the copying version of the splice() method.                                                                                                                                   |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [toSpliced(start, deleteCount, item1)](#tospliced-start-deletecount-item1)                           | It is the copying version of the splice() method.                                                                                                                                   |
| [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)       | [toSpliced(start, deleteCount, items)](#tospliced-start-deletecount-items)                           | It is the copying version of the splice() method.                                                                                                                                   |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)     | [unshift(value1, value2, valueN)](#unshift-value1-value2-valuen)                                     | Places element data at the start of an array.                                                                                                                                       |
| [Iterator](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/iterator) | [values()](#values)                                                                                  | The values() method of Array instances returns a new array iterator object that iterates the value of each item in the array.                                                       |

## Properties Detailed

### \[index]

Get an element by index.

**Type**\
[Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object)

**Sample**

```js
array[0]
```

### length

Get the length of the array.

**Type**\
[Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)

**Sample**

```js
array.length
```

## Methods Detailed

### at(index)

Takes an integer value and returns the item at that index, allowing for positive and negative integers. Negative integers count back from the last item in the array.

**Parameters**

* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **index** ;

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) The element in the array matching the given index.

**Sample**

```js
const arr = [1, 2, 3, 4, 5];
application.output(arr.at(2));
```

### concat(value1)

Returns a new array comprised of this array joined with other array(s) and/or value(s).

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **value1** ;

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)

**Sample**

```js
array.concat();
```

### concat(value1, value2)

Returns a new array comprised of this array joined with other array(s) and/or value(s).

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **value1** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **value2** ;

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)

**Sample**

```js
array.concat();
```

### concat(value1, value2, valueN)

Returns a new array comprised of this array joined with other array(s) and/or value(s).

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **value1** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **value2** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **valueN** ;

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)

**Sample**

```js
array.concat();
```

### copyWithin(target)

Shallow copies part of an array to another location in the same array and returns it without modifying its length

**Parameters**

* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **target** Zero-based index at which to copy the sequence to. If negative, target will be counted from the end.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)

**Sample**

```js
array.copyWithin(2);
```

### copyWithin(target, start)

Shallow copies part of an array to another location in the same array and returns it without modifying its length

**Parameters**

* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **target** Zero-based index at which to copy the sequence to. If negative, target will be counted from the end.
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **start** Zero-based index at which to start copying elements from. If negative, start will be counted from the end. If start is omitted, copyWithin will copy from index 0.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)

**Sample**

```js
array.copyWithin(2);
```

### copyWithin(target, start, end)

Shallow copies part of an array to another location in the same array and returns it without modifying its length

**Parameters**

* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **target** Zero-based index at which to copy the sequence to. If negative, target will be counted from the end.
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **start** Zero-based index at which to start copying elements from. If negative, start will be counted from the end. If start is omitted, copyWithin will copy from index 0.
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **end** Zero-based index at which to end copying elements from. copyWithin copies up to but not including end. If negative, end will be counted from the end.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)

**Sample**

```js
array.copyWithin(2);
```

### entries()

The entries() method of Array instances returns a new array iterator object that contains the key/value pairs for each index in the array.

**Returns:** [Iterator](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/iterator) the iterator

**Sample**

```js
const arr = [1, 2, 3, 4, 5];
const iterator = arr.entries();
```

### every(callback)

Runs a function on items in the array while that function is returning true. It returns true if the function returns true for every item it could visit.\
The callback function is invoked with three arguments: the element value, the element index, the array being traversed.

**Parameters**

* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **callback** ;

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)

**Sample**

```js
function isNumber(value) { return typeof value == 'number'; }
var a1 = [1, 2, 3];
application.output(a1.every(isNumber));
var a2 = [1, '2', 3];
application.output(a2.every(isNumber));
```

### every(callback, thisObject)

Runs a function on items in the array while that function is returning true. It returns true if the function returns true for every item it could visit.\
The callback function is invoked with three arguments: the element value, the element index, the array being traversed.

**Parameters**

* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **callback** ;
* [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) **thisObject** ;

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)

**Sample**

```js
function isNumber(value) { return typeof value == 'number'; }
var a1 = [1, 2, 3];
application.output(a1.every(isNumber));
var a2 = [1, '2', 3];
application.output(a2.every(isNumber));
```

### fill(value)

Changes all elements in an array to a static value, from a start index (default 0) to an end index (default array.length). It returns the modified array.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **value** Value to fill the array with.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)

**Sample**

```js
array.fill('test');
```

### fill(value, start)

Changes all elements in an array to a static value, from a start index (default 0) to an end index (default array.length). It returns the modified array.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **value** Value to fill the array with.
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **start** Zero-based index at which to start filling.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)

**Sample**

```js
array.fill('test');
```

### fill(value, start, end)

Changes all elements in an array to a static value, from a start index (default 0) to an end index (default array.length). It returns the modified array.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **value** Value to fill the array with.
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **start** Zero-based index at which to start filling.
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **end** Zero-based index at which to end filling.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)

**Sample**

```js
array.fill('test');
```

### filter(callback)

Runs a function on every item in the array and returns an array of all items for which the function returns true.\
The callback function is invoked with three arguments: the element value, the element index, the array being traversed.

**Parameters**

* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **callback** ;

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)

**Sample**

```js
var a1 = ['a', 10, 'b', 20, 'c', 30];
var a2 = a1.filter(function(item) { return typeof item == 'number'; });
application.output(a2);
```

### filter(callback, thisObject)

Runs a function on every item in the array and returns an array of all items for which the function returns true.\
The callback function is invoked with three arguments: the element value, the element index, the array being traversed.

**Parameters**

* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **callback** ;
* [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) **thisObject** ;

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)

**Sample**

```js
var a1 = ['a', 10, 'b', 20, 'c', 30];
var a2 = a1.filter(function(item) { return typeof item == 'number'; });
application.output(a2);
```

### find(callback)

Returns the value of the first element in the provided array that satisfies the provided testing function.\
&#x20;If no values satisfy the testing function, undefined is returned.\
&#x20;The callback function can invoked with three arguments: the element value, the element index(optional), the array being traversed (optional).

**Parameters**

* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **callback** a testing function

**Returns:** [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) the element which satisfies the function or undefined

**Sample**

```js
var array1 = [5, 12, 8, 130, 44];
 var found = array1.find(function(element) { return element > 10});
 application.output(found); // prints 12
```

### findIndex(callback)

Returns the index of the first element in the provided array which satisfies the provided testing function.\
&#x20;If no values satisfy the testing function, -1 is returned.\
&#x20;The callback function can invoked with three arguments: the element value, the element index (optional), the array being traversed (optional).

**Parameters**

* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **callback** a testing function

**Returns:** [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) the index of the first element which satisfies the function or -1

**Sample**

```js
var array1 = [5, 12, 8, 130, 44];
 var found = array1.findIndex(function(element) { return element > 10});
 application.output(found); // prints 1
```

### findLast(callback)

Iterates the array in reverse order and returns the value of the first element that satisfies the provided testing function.\
&#x20;If no elements satisfy the testing function, undefined is returned.\
&#x20;The callback function can invoked with three arguments: the element value, the element index (optional), the array being traversed (optional).

**Parameters**

* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **callback** a testing function

**Returns:** [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) the index of the first element which satisfies the function or undefined

**Sample**

```js
const array1 = [5, 12, 50, 130, 44];
 const found = array1.findLast((element) => element > 45);
 application.output(found); // prints 130
```

### findLastIndex(callback)

Iterates the array in reverse order and returns the index of the first element that satisfies the provided testing function.\
&#x20;If no elements satisfy the testing function, -1 is returned.\
&#x20;The callback function can invoked with three arguments: the element value, the element index (optional), the array being traversed (optional).

**Parameters**

* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **callback** a testing function

**Returns:** [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) the index of the first element which satisfies the function or undefined

**Sample**

```js
const array1 = [5, 12, 50, 130, 44];
 const found = array1.findLast((element) => element > 45);
 application.output(found); // prints 3
```

### flat()

The flat() method of Array instances creates a new array with all sub-array elements concatenated into it recursively up to the specified depth.\
Default depth is 1.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) new flat array

**Sample**

```js
const arr1 = [0, 1, 2, [3, 4]];
const newarr = arr.flat();
```

### flat(depth)

The flat() method of Array instances creates a new array with all sub-array elements concatenated into it recursively up to the specified depth.

**Parameters**

* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **depth** The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) new flat array

**Sample**

```js
const arr1 = [0, 1, 2, [3, 4, 5, [6, 7]]];
const newarr = arr.flat(2);
```

### flatMap(callback)

The flatMap() method of Array instances returns a new array formed by applying a given callback function to each element of the array, and then flattening the result by one level.\
It is identical to a map() followed by a flat() of depth 1, but slightly more efficient than calling those two methods separately.

**Parameters**

* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **callback** \`\`\` A function that produces an element of the new Array, taking three arguments: - element The current element being processed in the array. - index The index of the current element being processed in the array. - array The array flatMap() was called upon.

````


**Returns:** [Boolean](./boolean.md)

**Sample**

```js
const arr1 = [1, 2, 1];

const result = arr1.flatMap((num) => (num === 2 ? [2, 2] : 1));
````

### flatMap(callback, thisObject)

The flatMap() method of Array instances returns a new array formed by applying a given callback function to each element of the array, and then flattening the result by one level.\
It is identical to a map() followed by a flat() of depth 1, but slightly more efficient than calling those two methods separately.

**Parameters**

* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **callback** \`\`\` A function that produces an element of the new Array, taking three arguments: - element The current element being processed in the array. - index The index of the current element being processed in the array. - array The array flatMap() was called upon.

````

* [Array](./array.md) **thisObject** value to use as this when executing callback

**Returns:** [Boolean](./boolean.md)

**Sample**

```js
const arr1 = [1, 2, 1];

const result = arr1.flatMap((num) => (num === 2 ? [2, 2] : 1));
````

### forEach(callback)

Runs a function (callback) on every item in the array. The callback function is invoked only for indexes of the array which have assigned values.\
The callback function is invoked with three arguments: the element value, the element index, the array being traversed.

**Parameters**

* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **callback** ;

**Returns:** void

**Sample**

```js
function printThemOut(element, index, array) {
		application.output("a[" + index + "] = " + element);
}
var a = ['a', 'b', 'c'];
a.forEach(printThemOut);
```

### forEach(callback, thisObject)

Runs a function (callback) on every item in the array. The callback function is invoked only for indexes of the array which have assigned values.\
The callback function is invoked with three arguments: the element value, the element index, the array being traversed.

**Parameters**

* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **callback** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **thisObject** ;

**Returns:** void

**Sample**

```js
function printThemOut(element, index, array) {
		application.output("a[" + index + "] = " + element);
}
var a = ['a', 'b', 'c'];
a.forEach(printThemOut);
```

### from(value)

Creates a new, shallow-copied Array instance from an iterable or array-like object.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **value** An iterable or array-like object to convert to an array.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)

**Sample**

```js
var a = Array.from([1, 2, 3]);
```

### from(value, mapFunction, thisObject)

Creates a new, shallow-copied Array instance from an iterable or array-like object.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **value** An iterable or array-like object to convert to an array.
* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **mapFunction** Map function to call on every element of the array. If provided, every value to be added to the array is first passed through this function, and mapFunction's return value is added to the array instead.
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **thisObject** Value to use as this when executing mapFunction.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)

**Sample**

```js
var a = Array.from([1, 2, 3]);
```

### includes(searchElement)

Determines whether an array includes a certain value among its entries, returning true or false as appropriate.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **searchElement** The value to search for.

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)

**Sample**

```js
array.includes('test');
```

### includes(searchElement, start)

Determines whether an array includes a certain value among its entries, returning true or false as appropriate.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **searchElement** The value to search for.
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **start** Zero-based index at which to start searching.

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)

**Sample**

```js
array.includes('test');
```

### indexOf(searchElement)

Returns the first index at which a given element can be found in the array, or -1 if it is not present.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **searchElement** ;

**Returns:** [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)

**Sample**

```js
var a = ['a', 'b', 'a', 'b', 'a'];
application.output(a.indexOf('b'));
application.output(a.indexOf('b', 2));
application.output(a.indexOf('z'));
```

### indexOf(searchElement, fromIndex)

Returns the first index at which a given element can be found in the array, or -1 if it is not present.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **searchElement** ;
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **fromIndex** ;

**Returns:** [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)

**Sample**

```js
var a = ['a', 'b', 'a', 'b', 'a'];
application.output(a.indexOf('b'));
application.output(a.indexOf('b', 2));
application.output(a.indexOf('z'));
```

### isArray(obj)

Checks whether an object is an array or not.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **obj** ;

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)

**Sample**

```js
var a = [1, 2, 3];
application.output(Array.isArray(a)); //prints true
application.output(Array.isArray(23)); //prints false
```

### join(delimiter)

Puts all elements in the array into a string, separating each element with the specified delimiter

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **delimiter** ;

**Returns:** [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)

**Sample**

```js
var words = new Array("limit","lines","finish","complete","In","Out");
var jwords = words.join(";");
```

### js\_with(index, value)

It is the copying version of using the bracket notation to change the value of a given index.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **index** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **value** ;

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) a new array with the element at the given index replaced with the given value.

**Sample**

```js
const arr = [1, 2, 3, 4, 5];
application.output(arr.with(2, 6)); // [1, 2, 6, 4, 5]
```

### keys()

The keys() method of Array instances returns a new array iterator object that contains the keys for each index in the array.

**Returns:** [Iterator](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/iterator) the iterator

**Sample**

```js
const arr = [1, 2, 3, 4, 5];
const iterator = arr.keys();
```

### lastIndexOf(searchElement)

Returns the last index at which a given element can be found in the array, or -1 if it is not present. The array is searched backwards, starting at fromIndex.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **searchElement** ;

**Returns:** [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)

**Sample**

```js
var a = ['a', 'b', 'c', 'd', 'a', 'b'];
application.output(a.lastIndexOf('b'));
application.output(a.lastIndexOf('b', 4));
application.output(a.lastIndexOf('z'));
```

### lastIndexOf(searchElement, fromIndex)

Returns the last index at which a given element can be found in the array, or -1 if it is not present. The array is searched backwards, starting at fromIndex.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **searchElement** ;
* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **fromIndex** ;

**Returns:** [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)

**Sample**

```js
var a = ['a', 'b', 'c', 'd', 'a', 'b'];
application.output(a.lastIndexOf('b'));
application.output(a.lastIndexOf('b', 4));
application.output(a.lastIndexOf('z'));
```

### map(callback)

Runs a function on every item in the array and returns the results in an array.\
The callback function is invoked with three arguments: the element value, the element index, the array being traversed.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **callback** ;

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)

**Sample**

```js
var a = ['a', 'b', 'c'];
var a2 = a.map(function(item) { return item.toUpperCase(); });
application.output(a2);
```

### map(callback, thisObject)

Runs a function on every item in the array and returns the results in an array.\
The callback function is invoked with three arguments: the element value, the element index, the array being traversed.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **callback** ;
* [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) **thisObject** ;

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)

**Sample**

```js
var a = ['a', 'b', 'c'];
var a2 = a.map(function(item) { return item.toUpperCase(); });
application.output(a2);
```

### of(value)

Ccreates a new Array instance from a variable number of arguments.

**Parameters**

* [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) **value** ;

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)

**Sample**

```js
var a = Array.of(1, 2, 3);
```

### pop()

Pops the last string off the array and returns it.

**Returns:** [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object)

**Sample**

```js
var words = new Array("limit","lines","finish","complete","In","Out");
var lastword = words.pop();
```

### push(value1)

Mutates an array by appending the given elements and returning the new length of the array.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **value1** ;

**Returns:** [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)

**Sample**

```js
var words = new Array("limit","lines","finish","complete");
words.push("In","Out");
```

### push(value1, value2)

Mutates an array by appending the given elements and returning the new length of the array.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **value1** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **value2** ;

**Returns:** [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)

**Sample**

```js
var words = new Array("limit","lines","finish","complete");
words.push("In","Out");
```

### push(value1, value2, valueN)

Mutates an array by appending the given elements and returning the new length of the array.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **value1** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **value2** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **valueN** ;

**Returns:** [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)

**Sample**

```js
var words = new Array("limit","lines","finish","complete");
words.push("In","Out");
```

### reduce(f, initialValue)

Reduces the array to a single value by executing a provided function for each value of the array (from left-to-right).

**Parameters**

* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **f** Function to execute on each element in the array, taking four arguments:\
  &#x20;        -accumulator: accumulates the callback's return values; it is the accumulated value previously returned\
  &#x20;                         in the last invocation of the callback, or initialValue, if supplied (see below).\
  &#x20;           -currentValue: the current element being processed in the array.\
  &#x20;           -currentIndex (Optional): the index of the current element being processed in the array (starts at index 0,\
  &#x20;                         if an initialValue is provided, and at index 1 otherwise)\
  &#x20;           -array (Optional): the array reduce() was called upon.
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **initialValue** Value to use as the first argument to the first call of the callback. If no initial value is supplied,\
  &#x20;                      the first element in the array will be used.

**Returns:** [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) Object

**Sample**

```js
var euros = [29.76, 41.85, 46.5];
var sum = euros.reduce( function(total, amount) {
  return total + amount
});
```

### reduceRight(f)

The reduceRight() method of Array instances applies a function against an accumulator and each value of the array (from right-to-left) to reduce it to a single value.\
See also reduce() for left-to-right processing.

**Parameters**

* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **f** Function to execute on each element in the array, taking four arguments:\
  &#x20;        -accumulator: accumulates the callback's return values; it is the accumulated value previously returned\
  &#x20;                         in the last invocation of the callback, or initialValue, if supplied (see below).\
  &#x20;           -currentValue: the current element being processed in the array.\
  &#x20;           -currentIndex: the index of the current element being processed in the array (starts at index 0,\
  &#x20;                         if an initialValue is provided, and at index 1 otherwise)\
  &#x20;           -array : the array reduce() was called upon.

**Returns:** [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) Object The value that results from the reduction.

**Sample**

```js
var euros = [29.76, 41.85, 46.5];
var sum = euros.reduceRight( function(total, amount) {
  return total + amount
});
```

### reduceRight(f, initialValue)

The reduceRight() method of Array instances applies a function against an accumulator and each value of the array (from right-to-left) to reduce it to a single value.\
See also reduce() for left-to-right processing.

**Parameters**

* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **f** Function to execute on each element in the array, taking four arguments:\
  &#x20;        -accumulator: accumulates the callback's return values; it is the accumulated value previously returned\
  &#x20;                         in the last invocation of the callback, or initialValue, if supplied (see below).\
  &#x20;           -currentValue: the current element being processed in the array.\
  &#x20;           -currentIndex: the index of the current element being processed in the array (starts at index 0,\
  &#x20;                         if an initialValue is provided, and at index 1 otherwise)\
  &#x20;           -array : the array reduce() was called upon.
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **initialValue** Value to use as the first argument to the first call of the callback. If no initial value is supplied,\
  &#x20;                      the first element in the array will be used.

**Returns:** [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) Object The value that results from the reduction.

**Sample**

```js
var euros = [29.76, 41.85, 46.5];
var sum = euros.reduceRight( function(total, amount) {
  return total + amount
});
```

### reverse()

Puts array elements in reverse order.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)

**Sample**

```js
var words = new Array("limit","lines","finish","complete","In","Out");
words.reverse();
```

### shift()

Decreases array element size by one by shifting the first element off the array and returning it.

**Returns:** [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object)

**Sample**

```js
var words = new Array("limit","lines","finish","complete","In","Out");
words.shift();
```

### slice(begin)

The slice method creates a new array from a selected section of an array.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **begin** ;

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)

**Sample**

```js
var words = new Array("limit","lines","finish","complete","In","Out");
var nwords1 = words.slice(3, 5);
```

### slice(begin, end)

The slice method creates a new array from a selected section of an array.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **begin** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **end** ;

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)

**Sample**

```js
var words = new Array("limit","lines","finish","complete","In","Out");
var nwords1 = words.slice(3, 5);
```

### some(callback)

Runs a function on items in the array while that function returns false. It returns true if the function returns true for any item it could visit.\
The callback function is invoked with three arguments: the element value, the element index, the array being traversed.

**Parameters**

* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **callback** ;

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)

**Sample**

```js
function isNumber(value) { return typeof value == 'number'; }
var a1 = [1, 2, 3];
application.output(a1.some(isNumber));
var a2 = [1, '2', 3];
application.output(a2.some(isNumber));
```

### some(callback, thisObject)

Runs a function on items in the array while that function returns false. It returns true if the function returns true for any item it could visit.\
The callback function is invoked with three arguments: the element value, the element index, the array being traversed.

**Parameters**

* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **callback** ;
* [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) **thisObject** ;

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean)

**Sample**

```js
function isNumber(value) { return typeof value == 'number'; }
var a1 = [1, 2, 3];
application.output(a1.some(isNumber));
var a2 = [1, '2', 3];
application.output(a2.some(isNumber));
```

### sort()

Sorts the array elements in dictionary order or using a compare function passed to the method.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)

**Sample**

```js
var words = new Array("limit","lines","finish","complete","In","Out");
words.sort();
```

### sort(function)

Sorts the array elements in dictionary order or using a compare function passed to the method.

**Parameters**

* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **function** ;

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)

**Sample**

```js
var words = new Array("limit","lines","finish","complete","In","Out");
words.sort();
```

### splice(arrayIndex, length)

It is used to take elements out of an array and replace them with those specified.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **arrayIndex** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **length** ;

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)

**Sample**

```js
var words = new Array("limit","lines","finish","complete","In","Out");
var nwords1 = words.splice(3, 2, "done", "On");
```

### splice(arrayIndex, length, value1)

It is used to take elements out of an array and replace them with those specified.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **arrayIndex** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **length** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **value1** ;

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)

**Sample**

```js
var words = new Array("limit","lines","finish","complete","In","Out");
var nwords1 = words.splice(3, 2, "done", "On");
```

### splice(arrayIndex, length, value1, value2)

It is used to take elements out of an array and replace them with those specified.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **arrayIndex** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **length** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **value1** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **value2** ;

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)

**Sample**

```js
var words = new Array("limit","lines","finish","complete","In","Out");
var nwords1 = words.splice(3, 2, "done", "On");
```

### splice(arrayIndex, length, value1, value2, valueN)

It is used to take elements out of an array and replace them with those specified.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **arrayIndex** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **length** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **value1** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **value2** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **valueN** ;

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array)

**Sample**

```js
var words = new Array("limit","lines","finish","complete","In","Out");
var nwords1 = words.splice(3, 2, "done", "On");
```

### toReversed()

The toReversed() method transposes the elements of the calling array object in reverse order and returns a new array.\
When used on sparse arrays, the toReversed() method iterates empty slots as if they have the value undefined.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) a new array containing the elements in reversed order

**Sample**

```js
const items = [1, 2, 3];
application.output(items); // [1, 2, 3]
const reversedItems = items.toReversed();
application.output(reversedItems); // [3, 2, 1]
```

### toSorted()

It is the copying version of the sort() method. It returns a new array with the elements sorted in ascending order.\
The array elements are converted to strings, then sorted according to each character's Unicode code point value.\
When used on sparse arrays, the toSorted() method iterates empty slots as if they have the value undefined.

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) a new array containing the elements sorted in ascending order

**Sample**

```js
const months = ["Mar", "Jan", "Feb", "Dec"];
const sortedMonths = months.toSorted();
application.output(sortedMonths); // ['Dec', 'Feb', 'Jan', 'Mar']
```

### toSorted(comparator)

It is the copying version of the sort() method. It returns a new array with the elements sorted in ascending order.\
When used on sparse arrays, the toSorted() method iterates empty slots as if they have the value undefined.

**Parameters**

* [Function](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/function) **comparator** a comparator function

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) a new array containing the elements sorted in ascending order

**Sample**

```js
const values = [1, 10, 21, 2];
const sortedValues = values.toSorted((a, b) => a - b);
application.output(sortedValues); // [1, 2, 10, 21]
```

### toSpliced(start)

It is the copying version of the splice() method. It returns a new array with some elements removed and/or replaced at a given index.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **start** ;

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) a new array that consists of all elements before start

**Sample**

```js
const months = ["Jan", "Mar", "Apr", "May"];
const months2 = months.toSpliced(2);
application.output(months2); // ["Jan", "Mar"]
```

### toSpliced(start, deleteCount)

It is the copying version of the splice() method. It returns a new array with some elements removed and/or replaced at a given index.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **start** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **deleteCount** ;

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) a new array that consists of all elements before start and all elements after start + deleteCount.

**Sample**

```js
const months = ["Jan", "Mar", "Apr", "May"];
const months2 = months.toSpliced(2, 2);
application.output(months2); // ["Jan", "Mar", "May"]
```

### toSpliced(start, deleteCount, item1)

It is the copying version of the splice() method. It returns a new array with some elements removed and/or replaced at a given index.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **start** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **deleteCount** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **item1** ;

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) a new array that consists of all elements before start, adds item1 to the array (beginning from start) and all elements after start + deleteCount.

**Sample**

```js
const months = ["Jan", "Mar", "Apr", "May"];
const months2 = months.toSpliced(1, 0, "Feb");
application.output(months2); // ["Jan", "Feb", "Mar", "Apr", "May"]
```

### toSpliced(start, deleteCount, items)

It is the copying version of the splice() method. It returns a new array with some elements removed and/or replaced at a given index.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **start** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **deleteCount** ;
* [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) **items** ;

**Returns:** [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) a new array that consists of all elements before start, adds items to the array (beginning from start) and all elements after start + deleteCount.

**Sample**

```js
const months = ["Jan", "Feb", "May"];
const months2 = months.toSpliced(1, 1, "Feb", "Mar");
application.output(months2); // ["Jan", "Feb", "Mar", "May"]
```

### unshift(value1, value2, valueN)

Places element data at the start of an array.

**Parameters**

* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **value1** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **value2** ;
* [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) **valueN** ;

**Returns:** [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)

**Sample**

```js
var words = new Array("finish","complete","In","Out");
words.unshift("limit","lines");
```

### values()

The values() method of Array instances returns a new array iterator object that iterates the value of each item in the array.

**Returns:** [Iterator](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/iterator) the iterator

**Sample**

```js
const arr = [1, 2, 3, 4, 5];
const iterator = arr.values();
```

***
