Skip to content

arrayLength - Get number of elements in an array

arrayLength gets the number of elements in a given array.

Syntax

arrayLength(array: array<any>): number

Arguments

NameTypeRequiredDescription
arrayarray of type anytrueThe array to test

Example - Find out how many jobs are waiting

Consider the following document:

{
    "loading_jobs_waiting": ["loading_job1", "loading_job2", "loading_job3"]
}

If we wish to know how many loading jobs are waiting to be executed, we can use arrayLength:

create waiting_jobs from loading_jobs_waiting.arrayLength()

This results in the following document:

{
    "loading_jobs_waiting": ["loading_job1", "loading_job2", "loading_job3"],
    "waiting_jobs": 3
}