The _array
operator can be used to run javascript Array
methods.
Operator methods:
_array.concat
(arrays: any[][]): any[]
The _array.concat
method concatenates arrays.
_array.copyWithin
(arguments: {
on: any[],
target: number,
start?: number,
end?: number
}): any[]
(arguments: [
on: any[],
target: number,
start?: number,
end?: number
]): any[]
The _array.copyWithin
method copies part of an array to another location in the same array without modifying its length.
_array.every
(arguments: {
on: any[],
callback: function,
}): boolean
(arguments: [
on: any[],
callback: function,
]): boolean
The _array.every
method tests whether all elements in the array pass the test implemented by the provided function. It returns a Boolean value.
_array.fill
(arguments: {
on: any[],
value: any,
start?: number,
end?: number
}): any[]
(arguments: [
on: any[],
value: number,
start?: number,
end?: number
]): any[]
The _array.fill
method changes all elements in an array to a static value, from a start
index to an end
index.
_array.filter
(arguments: {
on: any[],
callback: function,
}): any[]
(arguments: [
on: any[],
callback: function,
]): any[]
The _array.filter
method returns an array with all elements that pass the test implemented by the provided function.
_array.find
(arguments: {
on: any[],
callback: function,
}): any
(arguments: [
on: any[],
callback: function,
]): any
The _array.find
method returns the value of the first element in the provided array that satisfies the provided testing function. If no values satisfies the testing function, undefined is returned.
_array.findIndex
(arguments: {
on: any[],
callback: function,
}): number
(arguments: [
on: any[],
callback: function,
]): number
The _array.findIndex
method returns the index of the first element in the array that satisfies the provided testing function. Otherwise, it returns -1, indicating that no element passed the test.
_array.flat
(arguments: {on: any[], depth?: number}): any[]
(arguments: [on: any[], depth?: number]): any[]
The _array.flat
method returns a array with all sub-array elements concatenated into it recursively up to the specified depth
.
_array.includes
(arguments: {on: any[], value: any}): boolean
(arguments: [on: any[], value: any]): boolean
The _array.includes
method determines whether an array includes a certain value among its entries, returning true
or false
as appropriate.
_array.indexOf
(arguments: {on: any[], value: any}): number
(arguments: [on: any[], value: any]): number
The _array.indexOf
method returns the first index at which a given element can be found in the array, or -1
if it is not present.
_array.join
(arguments: {on: any[], separator?: string}): string
(arguments: [on: any[], separator?: string]): string
The _array.join
method returns a string by concatenating all of the elements in an array, separated by commas or a specified separator
string. If the array has only one item, then that item will be returned without using the separator.
_array.lastIndexOf
(arguments: {on: any[], value: any}): number
(arguments: [on: any[], value: any]): number
The _array.lastIndexOf
method returns the last index at which a given element can be found in the array, or -1 if it is not present.
_array.length
(array: any[]}): number
The _array.length
method returns the number of elements in the array.
_array.map
(arguments: {
on: any[],
callback: function,
}): any[]
(arguments: [
on: any[],
callback: function,
]): any[]
The _array.map
method returns an array populated with the results of calling a provided function on every element in the provided array.
_array.reduce
(arguments: {
on: any[],
callback: function,
initialValue?: any
}): any
(arguments: [
on: any[],
callback: function,
initialValue?: any
]): any
The _array.reduce
method executes a reducer function on each element of the array, resulting in single output value.
Examples
The simplest example would probably be adding all the elements in an array:
sum:
_array.reduce:
on: [1, 2, 3, 4]
callback:
_function:
__sum:
- __args: 0
- __args: 1
This will return sum: 10
You can start off by counting from 10 by specifying an initialValue
for the reducer:
sum:
_array.reduce:
on: [1, 2, 3, 4]
callback:
_function:
__sum:
- __args: 0
- __args: 1
initialValue: 10
This will return sum: 20
You can use the index of the array element to add some logic to your callback
. For instance, when you reach index 2 of your array (the 3rd entry), add 100 instead of the current element value:
sum:
_array.reduce:
on: [1, 2, 3, 4]
callback:
_function:
__sum:
- __args: 0
- __if:
test:
__eq:
- __args: 2
- 2
then: 100
else:
__args: 1
This will return sum: 107
_array.reduceRight
(arguments: {
on: any[],
callback: function,
initialValue?: any
}): any
(arguments: [
on: any[],
callback: function,
initialValue?: any
]): any
The _array.reduceRight
method applies a function against an accumulator and each value of the array (from right-to-left) to reduce it to a single value.
_array.reverse
(array: any[]}): any[]
The _array.reverse
method reverses an array.
_array.slice
(arguments: {
on: any[],
start?: number,
end?: number
}): number
(arguments: [
on: any[],
start?: number,
end?: number
]): number
The _array.slice
method returns a portion of an array selected from start
to end
(end not included) where start
and end
represent the index of items in that array.
_array.some
(arguments: {
on: any[],
callback: function,
}): boolean
(arguments: [
on: any[],
callback: function,
]): boolean
The _array.some
method tests whether at least one element in the array passes the test implemented by the provided function. It returns a Boolean value.
_array.sort
(arguments: {on: any[]}): number
The _array.sort
method sorts the elements of an array. The sort order is ascending, built upon converting the elements into strings, then comparing their sequences of UTF-16 code units values.
_array.splice
(arguments: {
on: any[],
start: number,
deleteCount?: number
insert: any[]
}): number
(arguments: {
on: any[],
start: number,
deleteCount?: number,
insert: any[]
}): number
The _array.slice
method changes the contents of an array by removing or replacing existing elements and/or adding new elements.