Array#
Array.append()#
Description: Adds new elements to the end of the array. Similar to push(), but returns the modified array. Consider using spread syntax instead (see examples).
Syntax: Array.append(elem1, elem2?, ..., elemN?)
Returns: Array
Source: Custom n8n functionality
Parameters:
elem1(any) - The first element to appendelem2(any) - optional - The second element to appendelemN(any) - optional - The Nth element to append
Examples:
1 2 | |
1 2 3 4 5 | |
Array.average()#
Description: Returns the average of the numbers in the array. Throws an error if there are any non-numbers.
Syntax: Array.average()
Returns: Number
Source: Custom n8n functionality
Examples:
1 2 | |
Array.chunk()#
Description: Splits the array into an array of sub-arrays, each with the given length
Syntax: Array.chunk(length)
Returns: Array
Source: Custom n8n functionality
Parameters:
length(Number) - The number of elements in each chunk
Examples:
1 2 | |
Array.compact()#
Description: Removes any empty values from the array. null, "" and undefined count as empty.
Syntax: Array.compact()
Returns: Array
Source: Custom n8n functionality
Examples:
1 2 | |
Array.concat()#
Description: Joins one or more arrays onto the end of the base array
Syntax: Array.concat(array2, array3?, ... arrayN?)
Returns: Array
Source: JavaScript function
Parameters:
array2(Array) - The first array to be joined on the end of the base arrayarray3(Array) - optional - The second array to be joined on to the end of the base arrayarrayN(Array) - optional - The Nth array to be joined on to the end of the base array
Examples:
1 2 | |
1 2 3 4 | |
Array.difference()#
Description: Compares two arrays. Returns all elements in the base array that aren't present
in otherArray.
Syntax: Array.difference(otherArray)
Returns: Array
Source: Custom n8n functionality
Parameters:
otherArray(Array) - The array to compare to the base array
Examples:
1 2 | |
Array.filter()#
Description: Returns an array with only the elements satisfying a condition. The condition is a function that returns true or false.
Syntax: Array.filter(function(element, index?, array?), thisValue?)
Returns: Array
Source: JavaScript function
Parameters:
function()(function) - A function to run for each array element. If it returnstrue, the element will be kept. Consider using arrow function notation to save space.element(any) - The value of the current elementindex(Number) - optional - The position of the current element in the array (starting at 0)array(Array) - optional - The array being processed. Rarely needed.thisValue(any) - optional - A value passed to the function as itsthisvalue. Rarely needed.
Examples:
1 2 3 | |
1 2 3 4 5 6 | |
1 2 3 | |
Array.find()#
Description: Returns the first element from the array that satisfies the provided condition. The condition is a function that returns true or false. Returns undefined if no matches are found.
If you need all matching elements, use filter().
Syntax: Array.find(function(element, index?, array?), thisValue?)
Returns: any
Source: JavaScript function
Parameters:
function()(function) - A function to run for each array element. As soon as it returnstrue, that element will be returned. Consider using arrow function notation to save space.element(any) - The value of the current elementindex(Number) - optional - The position of the current element in the array (starting at 0)array(Array) - optional - The array of the current element. Rarely needed.thisValue(any) - optional - A value passed to the function as itsthisvalue. Rarely needed.
Examples:
1 2 3 | |
1 2 3 4 5 6 | |
Array.first()#
Description: Returns the first element of the array
Syntax: Array.first()
Returns: any
Source: Custom n8n functionality
Examples:
1 2 | |
Array.includes()#
Description: Returns true if the array contains the specified element
Syntax: Array.includes(element, start?)
Returns: Boolean
Source: JavaScript function
Parameters:
element(any) - The value to search the array forstart(Number) - optional - The index to start looking from
Examples:
1 2 3 | |
Array.indexOf()#
Description: Returns the position of the first matching element in the array, or -1 if the element isn’t found. Positions start at 0.
Syntax: Array.indexOf(element, start?)
Returns: Number
Source: JavaScript function
Parameters:
element(any) - The value to look forstart(Number) - optional - The index to start looking from
Examples:
1 2 | |
1 2 | |
Array.intersection()#
Description: Compares two arrays. Returns all elements in the base array that are also present in the other array.
Syntax: Array.intersection(otherArray)
Returns: Array
Source: Custom n8n functionality
Parameters:
otherArray(Array) - The array to compare to the base array
Examples:
1 2 | |
Array.isEmpty()#
Description: Returns true if the array has no elements or is null
Syntax: Array.isEmpty()
Returns: Boolean
Source: Custom n8n functionality
Examples:
1 2 | |
1 2 | |
Array.isNotEmpty()#
Description: Returns true if the array has at least one element
Syntax: Array.isNotEmpty()
Returns: Boolean
Source: Custom n8n functionality
Examples:
1 2 | |
1 2 | |
Array.join()#
Description: Merges all elements of the array into a single string, with an optional separator between each element.
The opposite of split().
Syntax: Array.join(separator?)
Returns: String
Source: JavaScript function
Parameters:
separator(String) - optional - The character(s) to insert between each element
Examples:
1 2 | |
1 2 3 | |
Array.last()#
Description: Returns the last element of the array
Syntax: Array.last()
Returns: any
Source: Custom n8n functionality
Examples:
1 2 | |
Array.length#
Description: The number of elements in the array
Syntax: Array.length
Returns: Number
Source: JavaScript function
Examples:
1 2 | |
Array.map()#
Description: Creates a new array by applying a function to each element of the original array
Syntax: Array.map(function(element, index?, array?), thisValue?)
Returns: Array
Source: JavaScript function
Parameters:
function()(function) - A function to run for each array element. In the new array, the output of this function takes the place of the element. Consider using arrow function notation to save space.element(any) - The value of the current elementindex(Number) - optional - The position of the current element in the array (starting at 0)array(Array) - optional - The array of the current element. Rarely needed.thisValue(any) - optional - A value passed to the function as itsthisvalue. Rarely needed.
Examples:
1 2 3 | |
1 2 3 4 5 6 | |
Array.max()#
Description: Returns the largest number in the array. Throws an error if there are any non-numbers.
Syntax: Array.max()
Returns: Number
Source: Custom n8n functionality
Examples:
1 2 | |
Array.min()#
Description: Returns the smallest number in the array. Throws an error if there are any non-numbers.
Syntax: Array.min()
Returns: Number
Source: Custom n8n functionality
Examples:
1 2 | |
Array.pluck()#
Description: Returns an array containing the values of the given field(s) in each Object of the array. Ignores any array elements that aren’t Objects or don’t have a key matching the field name(s) provided.
Syntax: Array.pluck(fieldName1?, fieldName2?, …)
Returns: Array
Source: Custom n8n functionality
Parameters:
fieldName1(String) - optional - The first key to retrieve the value offieldName2(String) - optional - The second key to retrieve the value of
Examples:
1 2 | |
1 2 | |
Array.randomItem()#
Description: Returns a randomly-chosen element from the array
Syntax: Array.randomItem()
Returns: any
Source: Custom n8n functionality
Examples:
1 2 3 | |
Array.reduce()#
Description: Reduces an array to a single value by applying a function to each element. The function combines the current element with the result of reducing the previous elements, producing a new result.
Syntax: Array.reduce(function(prevResult, currentElem, currentIndex?, array?), initResult)
Source: JavaScript function
Parameters:
function()(function) - A function to run for each array element. Takes the accumulated result and the current element, and returns a new accumulated result. Consider using arrow function notation to save space.prevResult(any) - The accumulated result from applying the function to previous elements. When processing the first element, it’s set toinitResult(or the first array element if not specified).currentElem(any) - The value in the array currently being processedcurrentIndex(Number) - optional - The position of the current element in the array (starting at 0)array(Array) - optional - The array being processed. Rarely needed.initResult(any) - optional - The initial value of the prevResult, used when calling the function on the first array element. When not specified it’s set to the first array element, and the first function call is on the second array element instead of the first.
Examples:
1 2 3 | |
1 2 3 4 5 6 | |
Array.removeDuplicates()#
Description: Removes any re-occurring elements from the array
Syntax: Array.removeDuplicates(keys?)
Returns: Array
Source: Custom n8n functionality
Parameters:
keys(String) - optional - For use on arrays of Objects. A key, or comma-separated list of keys to restrict the check to. If omitted, all keys are checked.
Examples:
1 2 | |
Array.renameKeys()#
Description: Changes all matching keys (field names) of any Objects in the array. Rename more than one key by
adding extra arguments, i.e. from1, to1, from2, to2, ....
Syntax: Array.renameKeys(from, to)
Returns: Array
Source: Custom n8n functionality
Parameters:
from(String) - The key to renameto(String) - The new key name
Examples:
1 2 | |
Array.reverse()#
Description: Reverses the order of the elements in the array
Syntax: Array.reverse()
Returns: Array
Source: JavaScript function
Examples:
1 2 | |
Array.slice()#
Description: Returns a portion of the array, from the start index up to (but not including) the end index. Indexes start at 0.
Syntax: Array.slice(start, end)
Returns: Array
Source: JavaScript function
Parameters:
start(Number) - optional - The position to start from. Positions start at 0. Negative numbers count back from the end of the array.end(Number) - optional - The position to select up to. The element at the end position is not included. Negative numbers select from the end of the array. If omitted, will extract to the end of the array.
Examples:
1 2 | |
1 2 | |
1 2 | |
Array.smartJoin()#
Description: Creates a single Object from an array of Objects. Each Object in the array provides one field for the returned Object. Each Object in the array must contain a field with the key name and a field with the value.
Syntax: Array.smartJoin(keyField, nameField)
Returns: Object
Source: Custom n8n functionality
Parameters:
keyField(String) - The field in each Object containing the key namenameField(String) - The field in each Object containing the value
Examples:
1 2 | |
Array.sort()#
Description: Reorders the elements of the array. For sorting strings alphabetically, no parameter is required. For sorting numbers or Objects, see examples.
Syntax: Array.sort(compareFunction(a, b)?)
Returns: Array
Source: JavaScript function
Parameters:
compareFunction(function) - optional - A function to compare two array elements and return a number indicating which one comes first: Return < 0:acomes beforebReturn 0:aandbare equal (leave order unchanged) Return > 0:bcomes beforea
If no function is specified, converts all values to strings and compares their character codes.
* a (any) - The first element to compare in the function
* b (any) - The second element to compare in the function
Examples:
1 2 3 | |
1 2 3 4 5 6 | |
1 2 3 | |
1 2 3 | |
Array.sum()#
Description: Returns the total of all the numbers in the array. Throws an error if there are any non-numbers.
Syntax: Array.sum()
Returns: Number
Source: Custom n8n functionality
Examples:
1 2 | |
Array.toJsonString()#
Description: Converts the array to a JSON string. The same as JavaScript’s JSON.stringify().
Syntax: Array.toJsonString()
Returns: String
Source: Custom n8n functionality
Examples:
1 2 | |
Array.toSpliced()#
Description: Adds and/or removes array elements at a given position.
See also slice() and append().
Syntax: Array.toSpliced(start, deleteCount, elem1, ....., elemN)
Returns: Array
Source: JavaScript function
Parameters:
start(Number) - The index (position) to add or remove elements at. New elements are inserted before the element at this index. A negative index counts back from the end of the array.deleteCount(Number) - optional - The number of elements to remove. If omitted, removes all elements from thestartindex onwards.elem1(any) - optional - The first new element to be addedelem2(any) - optional - The second new element to be addedelemN(any) - optional - The Nth new element to be added
Examples:
1 2 3 | |
1 2 3 | |
1 2 3 | |
Array.toString()#
Description: Converts the array to a string, with values separated by commas. To use a different separator, use join() instead.
Syntax: Array.toString()
Returns: String
Source: JavaScript function
Examples:
1 2 | |
Array.union()#
Description: Concatenates two arrays and then removes any duplicates
Syntax: Array.union(otherArray)
Returns: Array
Source: Custom n8n functionality
Parameters:
otherArray(Array) - The array to union with the base array
Examples:
1 2 | |
Array.unique()#
Description: Removes any duplicate elements from the array
Syntax: Array.unique()
Returns: Array
Source: Custom n8n functionality
Examples:
1 2 | |