# Global

This is the global namespace. Functions are available without having to prepend them with a namespace identifier.

### Static properties

#### Image *any*

HTML Image.

### Methods

#### NUM

```javascript
NUM(number: number, numDecimals?: number)
```

Returns a formatted number as a string. If a culture is specified when executing a ruleset, the formatting of that culture will be used.

**Parameters**

&#x20;   **number&#x20;*****number***

&#x20;       A numeric value.

&#x20;   **numDecimals&#x20;*****number***

&#x20;       (optional) The number of decimals. Defaults to 0.

**Return type**

&#x20;   string

**Examples**

```javascript
NUM(3)          // => "3"
NUM(3.99)       // => "3.99"
NUM(3.99)       // => "3,99" (when {culture:'nl'} is specified in execution options)
NUM(3.99, 1)    // => "4.0"
NUM(3.99, 0)    // => "4"
```

#### CUR

```javascript
CUR(number: number, numDecimals?: number)
```

Returns a formatted currency number as a string. If a culture is specified when executing a ruleset, the formatting of that culture will be used.

**Parameters**

&#x20;   **number&#x20;*****number***

&#x20;       A numeric value.

&#x20;   **numDecimals&#x20;*****number***

&#x20;       (optional) The number of decimals. Defaults to 2.

**Return type**

&#x20;   string

**Examples**

```javascript
CUR(3)          // => "3.00"
CUR(3.99)       // => "3.99" (default)
CUR(3.99)       // => "£3.99"  (when {culture:'en-GB'} is specified in execution options)
CUR(3.99)       // => "$3.99"  (when {culture:'en-US'} is specified in execution options)
CUR(3.99)       // => "€ 3,99" (when {culture:'nl'} is specified in execution options)
CUR(3.99, 1)    // => "4.0"
CUR(3.99, 0)    // => "4"
```

#### CURN

```javascript
CURN(number: number, numDecimals?: number)
```

Returns a formatted currency number as a string without the currency symbol. If a culture is specified when executing a ruleset, the formatting of that culture will be used.

**Parameters**

&#x20;   **number&#x20;*****number***

&#x20;       A numeric value.

&#x20;   **numDecimals&#x20;*****number***

&#x20;       (optional) The number of decimals. Defaults to 2.

**Return type**

&#x20;   string

**Examples**

```javascript
CURN(3)          // => "3.00"
CURN(3.99)       // => "3.99" (default)
CURN(3.99)       // => "3,99" (when {culture:'nl'} is specified in execution options)
CURN(3.99, 1)    // => "4.0"
CURN(3.99, 0)    // => "4
```

#### DATESTR

```javascript
DATESTR(date: Date | string, options?: Intl.DateTimeFormatOptions)
```

Returns a formatted date as a string. If a culture is specified when executing a ruleset, the formatting of that culture will be used.\
See [Intl.DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#options) for more information on the formatting options.

**Parameters**

&#x20;   **date&#x20;*****Date | string***

&#x20;       A JavaScript Date object or an ISO 8601 formatted string.

&#x20;   **options** [***Intl.DateTimeFormatOptions***](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#options)

&#x20;       (optional) The formatting options.

**Return type**

&#x20;   string

**Examples**

```javascript
DATESTR(TODAY())       // => "10-11-2025" (when {culture:'nl'} is specified in execution options)
DATESTR(TODAY())       // => "11/10/2025" (when {culture:'en'} is specified in execution options)

// Custom formatting:
DATESTR(TODAY(), {year:'numeric', month:'long', day:'numeric'})
// => "10 november 2025" (when {culture:'nl'} is specified in execution options)

DATESTR(TODAY(), {year:'numeric', month:'long', day:'numeric'})
// => "November 10, 2025" (when {culture:'en'} is specified in execution options)
```

#### AGE

```javascript
AGE(birthDate: Date | string)
```

Returns the amount of full years passed since a given JavaScript Date Object.

**Parameters**

&#x20;   **birthDate&#x20;*****Date | string***

&#x20;       A JavaScript Date object or an ISO 8601 formatted string.

**Return type**

&#x20;   number

**Examples**

```javascript
AGE(DATE('1980-01-01'))  // => 45
AGE('1986-01-01')        // => 39
```

#### DATE

```javascript
DATE(year: number | string | Date, month?: number, day?: number)
```

Creates a JavaScript Date Object. Is more reliable than using 'new Date()' to create a date, as DATE() ignores timezones.

**Parameters**

&#x20;   **year&#x20;*****number | string | Date***

&#x20;       The year or a YYYY-MM-DD string.

&#x20;   **month&#x20;*****number***

&#x20;       (optional) The month. 1-based (1=January, 2=February, etc.).

&#x20;   **day&#x20;*****number***

&#x20;       (optional) The day.

**Return type**

&#x20;   Date

**Examples**

```javascript
DATE(2000, 1, 1)               // => (Date) 2000-01-01T00:00:00.000Z - Note the month is 1-based (1=January)
DATE('2000-01-01')             // => (Date) 2000-01-01T00:00:00.000Z
DATE('2000-01-01T00:00')       // => (Date) 2000-01-01T00:00:00.000Z

For comparison:
new Date(2000, 1, 1)           // => (Date) 2000-01-31T23:00:00.000Z - Note the month is 0-based (0=January)
new Date('2000-01-01')         // => (Date) 2000-01-01T00:00:00.000Z
new Date('2000-01-01T00:00')   // => (Date) 1999-12-31T23:00:00.000Z
```

#### TODAY

```javascript
TODAY()
```

Returns the current date as a JavaScript Date Object at the start of the day (midnight, 00:00).

**Parameters**

**Return type**

&#x20;   Date

**Examples**

```javascript
TODAY()        // => (Date) 2025-11-10T00:00:00.000Z
```

#### NOW

```javascript
NOW()
```

Returns the current date and time as a JavaScript Date Object accurate to the millisecond.

**Parameters**

**Return type**

&#x20;   Date

**Examples**

```javascript
NOW()          // => (Date) 2025-11-10T15:09:19.502Z
```

#### DAY

```javascript
DAY(date: Date | string)
```

Returns the day of a given JavaScript Date Object.

**Parameters**

&#x20;   **date&#x20;*****Date | string***

&#x20;       A JavaScript Date object or an ISO 8601 formatted string.

**Return type**

&#x20;   number

**Examples**

```javascript
DAY(TODAY())       // => 10
```

#### WEEKDAY

```javascript
WEEKDAY(date: Date | string)
```

Returns the day of the week of a given JavaScript Date Object. Differs from JS Date's getDay() method, in that it is 1-based. (e.g. Sunday = 1, instead of 0. Saturday = 7)

**Parameters**

&#x20;   **date&#x20;*****Date | string***

&#x20;       A JavaScript Date object or an ISO 8601 formatted string.

**Return type**

&#x20;   number

**Examples**

```javascript
WEEKDAY(TODAY())       // => 2 (Monday = 2)
```

#### MONTH

```javascript
MONTH(date: Date | string)
```

Returns the month of a given JavaScript Date Object. Differs from JS Date's getMonth() method, in that it is 1-based. (e.g. January = 1, instead of 0.)

**Parameters**

&#x20;   **date&#x20;*****Date | string***

&#x20;       A JavaScript Date object or an ISO 8601 formatted string.

**Return type**

&#x20;   number

**Examples**

```javascript
MONTH(TODAY())     // => 11
```

#### YEAR

```javascript
YEAR(date: Date | string)
```

Returns the year of a given JavaScript Date Object.

**Parameters**

&#x20;   **date&#x20;*****Date | string***

&#x20;       A JavaScript Date object or an ISO 8601 formatted string.

**Return type**

&#x20;   number

**Examples**

```javascript
YEAR(TODAY())      // => 2025
```

#### YEARMONTH

```javascript
YEARMONTH(date: Date | string)
```

Returns the year and month of a given JavaScript Date Object.

**Parameters**

&#x20;   **date&#x20;*****Date | string***

&#x20;       A JavaScript Date object or an ISO 8601 formatted string.

**Return type**

&#x20;   string

**Examples**

```javascript
YEARMONTH(TODAY())     // => "2025-11"
```

#### YEARMONTHDAY

```javascript
YEARMONTHDAY(date: Date | string)
```

Returns the year, month and day of a given JavaScript Date Object. Note: this is similar to calling .toShortDateString() on a Date. See also:

* Date.toShortDateString

**Parameters**

&#x20;   **date&#x20;*****Date | string***

&#x20;       A JavaScript Date object or an ISO 8601 formatted string.

**Return type**

&#x20;   string

**Examples**

```javascript
YEARMONTHDAY(TODAY())          // => "2025-11-10"
TODAY().toShortDateString()    // => "2025-11-10"
```

#### MONTHDAY

```javascript
MONTHDAY(date: Date | string)
```

Returns the month and day of a given JavaScript Date Object.

**Parameters**

&#x20;   **date&#x20;*****Date | string***

&#x20;       A JavaScript Date object or an ISO 8601 formatted string.

**Return type**

&#x20;   string

**Examples**

```javascript
MONTHDAY(TODAY())          // => "11-10"
```

#### DAYDIFF

```javascript
DAYDIFF(dateFrom: Date | string, dateTo: Date | string)
```

Returns the amount of full days between two dates. See also:

* Date.diff

**Parameters**

&#x20;   **dateFrom&#x20;*****Date | string***

&#x20;       A JavaScript Date object or an ISO 8601 formatted string.

&#x20;   **dateTo&#x20;*****Date | string***

&#x20;       A JavaScript Date object or an ISO 8601 formatted string.

**Return type**

&#x20;   number

**Examples**

```javascript
DAYDIFF(DATE('2010-01-01'), DATE('2011-01-01'))                    // => 365 
DAYDIFF(DATE('2000-01-01T12:00:00'), DATE('2000-01-02T11:59:59'))  // => 0 
DAYDIFF(DATE('2000-01-01T12:00:00'), DATE('2000-01-02T12:00:00'))  // => 1 
```

#### SAMEDAY

```javascript
SAMEDAY(dateA: Date | string, dateB: Date | string)
```

Returns whether two dates are on the same day. See also:

* Date.isSameDay

**Parameters**

&#x20;   **dateA&#x20;*****Date | string***

&#x20;       A JavaScript Date object or an ISO 8601 formatted string.

&#x20;   **dateB&#x20;*****Date | string***

&#x20;       A JavaScript Date object or an ISO 8601 formatted string.

**Return type**

&#x20;   boolean

**Examples**

```javascript
SAMEDAY(DATE('2011-01-01'), DATE('2011-01-01'))                    // => true 
SAMEDAY(DATE('2000-01-01T00:00:00'), DATE('2000-01-01T23:59:59'))  // => true 
SAMEDAY(DATE('2000-01-01'), DATE('2000-01-02'))                    // => false 
```

#### MONTHDIFF

```javascript
MONTHDIFF(dateFrom: Date | string, dateTo: Date | string)
```

Returns the amount of full months between two dates. See also:

* Date.diff

**Parameters**

&#x20;   **dateFrom&#x20;*****Date | string***

&#x20;       A JavaScript Date object or an ISO 8601 formatted string.

&#x20;   **dateTo&#x20;*****Date | string***

&#x20;       A JavaScript Date object or an ISO 8601 formatted string.

**Return type**

&#x20;   number

**Examples**

```javascript
MONTHDIFF(DATE('1980-01-01'), DATE('2000-01-01'))          // => 240 
MONTHDIFF(DATE('1980-01-01'), DATE('2000-01-15'))          // => 240 
MONTHDIFF(DATE('1980-01-15'), DATE('2000-01-01'))          // => 239 
MONTHDIFF('2020-04-16T15:37:25.579Z', '2023-06-01T15:37:25.578Z')  // => 37 
```

#### YEARDIFF

```javascript
YEARDIFF(dateFrom: Date | string, dateTo: Date | string)
```

Returns the amount of full years between two dates. See also:

* Date.diff

**Parameters**

&#x20;   **dateFrom&#x20;*****Date | string***

&#x20;       A JavaScript Date object or an ISO 8601 formatted string.

&#x20;   **dateTo&#x20;*****Date | string***

&#x20;       A JavaScript Date object or an ISO 8601 formatted string.

**Return type**

&#x20;   number

**Examples**

```javascript
YEARDIFF(DATE('1980-01-01'), DATE('2000-01-01'))      // => 20 
YEARDIFF(DATE('1980-01-02'), DATE('2000-01-01'))      // => 19 
```

#### DATEDIFF

```javascript
DATEDIFF(dateFrom: Date | string, dateTo: Date | string, absolute?: boolean)
```

Returns an object containing the difference between two dates in various units. The output is similar to Date.diff(). See also:

* Date.diff

**Parameters**

&#x20;   **dateFrom&#x20;*****Date | string***

&#x20;       A JavaScript Date object or an ISO 8601 formatted string.

&#x20;   **dateTo&#x20;*****Date | string***

&#x20;       A JavaScript Date object or an ISO 8601 formatted string.

&#x20;   **absolute&#x20;*****boolean***

&#x20;       (optional) If true, will return a positive value for the difference.

**Return type**

&#x20;   DateDiffResult

**Examples**

```javascript
DATEDIFF(DATE('1980-01-01'), DATE('2000-01-01'))      // => 
        {
            totalMilliseconds: 631152000000,
            totalSeconds: 631152000,
            totalMinutes: 10519200,
            totalHours: 175320,
            totalDays: 7305,
            totalMonths: 240,                                
            totalYears: 20,
            totalFullSeconds: 631152000,
            totalFullMinutes: 10519200,
            totalFullHours: 175320,
            totalFullDays: 7305,
            totalFullMonths: 240,                                
            totalFullYears: 20
        }
```

#### ABS

```javascript
ABS(x: number)
```

Shorthand for Math.abs()

**Parameters**

&#x20;   **x&#x20;*****number***

&#x20;       A number.

**Return type**

&#x20;   number

**Examples**

```javascript
ABS(1)     // => 1
ABS(-1)    // => 1
```

#### CEIL

```javascript
CEIL(x: number, numDecimals?: number)
```

Returns the smallest integer greater than or equal to a given number.

**Parameters**

&#x20;   **x&#x20;*****number***

&#x20;       A number.

&#x20;   **numDecimals&#x20;*****number***

&#x20;       (optional) Number of decimals. Can be negative to round down to number of integers.

**Return type**

&#x20;   number

**Examples**

```javascript
CEIL(1)            // => 1
CEIL(1.1)          // => 2
CEIL(1.501, 1)     // => 1.6

// A negative numDecimals will round down to number of integers:
CEIL(1948, -1)     // => 1950
CEIL(1948, -2)     // => 2000
CEIL(1948, -3)     // => 2000

// Note that CEIL always rounds up, so for negative numbers it will round towards zero:
CEIL(-1.1)         // => -1
CEIL(-1.5)         // => -1
CEIL(-1.9)         // => -1
CEIL(-1.501, 1)    // => -1.5
```

#### FLOOR

```javascript
FLOOR(x: number, numDecimals?: number)
```

Returns the largest integer less than or equal to a given number.

**Parameters**

&#x20;   **x&#x20;*****number***

&#x20;       A number.

&#x20;   **numDecimals&#x20;*****number***

&#x20;       (optional) Number of decimals. Can be negative to round down to number of integers.

**Return type**

&#x20;   number

**Examples**

```javascript
FLOOR(1)            // => 1
FLOOR(1.9)          // => 1
FLOOR(1.501, 1)     // => 1.5

// A negative numDecimals will round down to number of integers:
FLOOR(1948, -1)     // => 1940
FLOOR(1948, -2)     // => 1900
FLOOR(1948, -3)     // => 1000

// Note that FLOOR always rounds down, so for negative numbers it will round away from zero:
FLOOR(-1.1)         // => -2
FLOOR(-1.5)         // => -2
FLOOR(-1.9)         // => -2
```

#### ROUND

```javascript
ROUND(x: number, numDecimals?: number)
```

Returns the value of a number rounded to the nearest integer, using the 'Half Away From Zero' rounding mode.

**Parameters**

&#x20;   **x&#x20;*****number***

&#x20;       A number.

&#x20;   **numDecimals&#x20;*****number***

&#x20;       (optional) Number of decimals. Can be negative to round down to number of integers.

**Return type**

&#x20;   number

**Examples**

```javascript
ROUND(1.4)          // => 1
ROUND(1.5)          // => 2
ROUND(1.501, 1)     // => 1.5

// A negative numDecimals will round down to number of integers:
ROUND(1948, -1)     // => 1950
ROUND(1948, -2)     // => 1900
ROUND(1948, -3)     // => 2000

// Note that ROUND default rounds negative numbers away from zero when .5:
ROUND(-21.4)         // => -21
ROUND(-21.5)         // => -22
ROUND(-21.51)        // => -22
```

#### LOG

```javascript
LOG(x: number)
```

Shorthand for Math.log() - returns the natural logarithm (base e) of the given number.

**Parameters**

&#x20;   **x&#x20;*****number***

&#x20;       A number.

**Return type**

&#x20;   number

**Examples**

```javascript
LOG(8) / LOG(2)    // => 3  (for 2 x 2 x 2 = 8)
LOG(625) / LOG(5)  // => 4  (for 5 x 5 x 5 x 5 = 625)
```

#### EXP

```javascript
EXP(x: number)
```

Shorthand for Math.exp() - returns ex, where x is the argument, and e is Euler's number (also known as Napier's constant), the base of the natural logarithms.

**Parameters**

&#x20;   **x&#x20;*****number***

&#x20;       A number.

**Return type**

&#x20;   number

**Examples**

```javascript
EXP(0)     // => 1
EXP(1)     // => 2.718281828459045
EXP(-1)    // => 0.36787944117144233
EXP(2)     // => 7.38905609893065
```

#### POW

```javascript
POW(base: number, exponent: number)
```

Shorthand for Math.pow() - returns the base to the exponent power. Note: for performance reasons it is better to use the \*\* operator instead of POW or Math.pow.

**Parameters**

&#x20;   **base&#x20;*****number***

&#x20;       The base number.

&#x20;   **exponent&#x20;*****number***

&#x20;       The exponent used to raise the base.

**Return type**

&#x20;   number

**Examples**

```javascript
POW(2, 3)      // => 8
POW(4, 0.5)    // => 2
POW(7, -2)     // => 0.02040816326530612 (1/49)
```

#### SQRT

```javascript
SQRT(x: number)
```

Shorthand for Math.sqrt() - returns the square root of a number.

**Parameters**

&#x20;   **x&#x20;*****number***

&#x20;       A number.

**Return type**

&#x20;   number

**Examples**

```javascript
SQRT(9)      // => 3
SQRT(2)      // => 1.4142135623730951
SQRT(1)      // => 1
```

#### MIN

```javascript
MIN(...numbers: number[])
```

Returns the lowest-valued number passed into it.

**Parameters**

&#x20;   **...numbers&#x20;*****number\[]***

&#x20;       Numbers.

**Return type**

&#x20;   number

**Examples**

```javascript
MIN(2, 3)         // => 2
MIN(-2, 3, -1)    // => -2
MIN([-2, 3, -1])  // You can pass in an array of numbers, too => -2
```

#### MAX

```javascript
MAX(...numbers: number[])
```

Returns the highest-valued number passed into it.

**Parameters**

&#x20;   **...numbers&#x20;*****number\[]***

&#x20;       Numbers.

**Return type**

&#x20;   number

**Examples**

```javascript
MAX(2, 3)          // => 3
MAX(-2, -3, -1)    // => -1
MAX([-2, -3, -1])  // You can pass in an array, too => -1
```

#### CLAMP

```javascript
CLAMP(input: number, min: number, max: number)
```

Combines the logic of MIN and MAX - Clamps the input number between the min and max values.

**Parameters**

&#x20;   **input&#x20;*****number***

&#x20;       The input value to be clamped.

&#x20;   **min&#x20;*****number***

&#x20;       Lowest possible value to clamp the input to.

&#x20;   **max&#x20;*****number***

&#x20;       Highest possible value to clamp the input to.

**Return type**

&#x20;   number

**Examples**

```javascript
CLAMP(5, 0, 10)    // => 5 // 5 is between 0 and 10, so value is not clamped
CLAMP(-1, 0, 10)   // => 0 // -1 is lower than 0, so value is clamped to 0
CLAMP(11, 0, 10)   // => 10 // 11 is higher than 10, so value is clamped to 10
```

#### WRAP

```javascript
WRAP(value: number, min: number, max: number)
```

Wraps a number within a given range. If the number exceeds the range, it will wrap around.

**Parameters**

&#x20;   **value&#x20;*****number***

&#x20;       The input value to be wrapped.

&#x20;   **min&#x20;*****number***

&#x20;       The minimum value of the range.

&#x20;   **max&#x20;*****number***

&#x20;       The maximum value of the range.

**Return type**

&#x20;   number

**Examples**

```javascript
WRAP(0, 0, 10)    // => 0
WRAP(1, 0, 10)    // => 1
WRAP(9, 0, 10)    // => 9
WRAP(10, 0, 10)   // => 10
WRAP(11, 0, 10)   // => 0

WRAP(-1, 0, 10)   // => 10
WRAP(-2, 0, 10)   // => 9
WRAP(-9, 0, 10)   // => 1
WRAP(-10, 0, 10)  // => 0
WRAP(-11, 0, 10)  // => 10
WRAP(-12, 0, 10)  // => 9
```

#### MAP

```javascript
MAP(value: number, startA: number, endA: number, startB: number, endB: number, clamp?: boolean)
```

Maps a number from one range to another

**Parameters**

&#x20;   **value&#x20;*****number***

&#x20;       The input value to be mapped.

&#x20;   **startA&#x20;*****number***

&#x20;       Current value range start.

&#x20;   **endA&#x20;*****number***

&#x20;       Current value range end.

&#x20;   **startB&#x20;*****number***

&#x20;       Target range start.

&#x20;   **endB&#x20;*****number***

&#x20;       Target range end.

&#x20;   **clamp&#x20;*****boolean***

&#x20;       (optional) Clamp the mapped value between target range. Defaults to false.

**Return type**

&#x20;   number

**Examples**

```javascript
MAP(50, 0, 100, 0, 1)          // => 0.5   // Map value 50 in range (0-100) to range (0-1)
MAP(50, 0, 100, -100, 100)     // => 0     // Map value 50 in range (0-100) to range (-100-100)
MAP(50, 0, 100, 100, 200)      // => 150   // Map value 50 in range (0-100) to range (100-200)
MAP(101, 0, 100, 0, 1)         // => 1.01  // Map value 101 in range (0-100) to range (0-1)
MAP(101, 0, 100, 0, 1, true)   // => 1     // Map and clamp value 101 in range (0-100) to range (0-1)
```

#### SOLVE

```javascript
SOLVE(fn: (x: number) => number, target: number, start?: number, step?: number, accuracy?: number, maxIterations?: number)
```

Attempt to find the input value that produces a given target result for a given function.

**Parameters**

&#x20;   **fn&#x20;*****(x: number) => number***

&#x20;       The function to find the input for. Must have exactly one parameter (number) and must return a number.

&#x20;   **target&#x20;*****number***

&#x20;       The target result value.

&#x20;   **start&#x20;*****number***

&#x20;       (optional) The input to start from. Defaults to 0.

&#x20;   **step&#x20;*****number***

&#x20;       (optional) The initial step size. Defaults to 100.

&#x20;   **accuracy&#x20;*****number***

&#x20;       (optional) The desired accuracy. If 0 is specified, the result must match exactly. Defaults to 1e-15.

&#x20;   **maxIterations&#x20;*****number***

&#x20;       (optional) The maximum number of attempts to solve for the input. Defaults to 100.

**Return type**

&#x20;   number

**Examples**

```javascript
// Solves x + 1 = 5:
SOLVE(x => x + 1, 5) // => 4

// Solves SQRT(x) = 5:
SOLVE(x => SQRT(x), 5) // => 25

// Solves x for result 9 (x * x = 9):
SOLVE(x => x * x, 9) // => 3

// Solves x for result 9 (x * x = 9) with all parameters:
SOLVE(
    x => x * x,       // Function
    9,                // Goal
    0,                // Start
    10,               // Initial step size
    0,                // Accuracy (0 = exact)
    10)               // Max attempts
```

#### RANDOM

```javascript
RANDOM(start?: number, end?: number)
```

Returns a floating-point, pseudo-random number in the range 0-1 (inclusive of 0, but not 1). If you pass in one parameter, it will return a random number between 0 and that number. When you pass in two parameters, it will return a random number between those two numbers.

**Parameters**

&#x20;   **start&#x20;*****number***

&#x20;       (optional) The lower limit. Defaults to 0.

&#x20;   **end&#x20;*****number***

&#x20;       (optional) The upper limit. Defaults to 1. The value itself is not included in the range.

**Return type**

&#x20;   number

**Examples**

```javascript
RANDOM()         // => 0.5613144182432424
RANDOM()         // => 0.30579935965425176
RANDOM(100)      // => 90.58933435341065
RANDOM(100)      // => 6.704863558513974
RANDOM(-10, 10)  // => -1.6273603037658724
RANDOM(-10, 10)  // => -7.927345330572342
```

#### RANDOMINT

```javascript
RANDOMINT(start: number, end: number)
```

Returns an integer, pseudo-random number in a given range. It will return a random number between those two numbers, including those two numbers.

**Parameters**

&#x20;   **start&#x20;*****number***

&#x20;       The lower limit.

&#x20;   **end&#x20;*****number***

&#x20;       The upper limit.

**Return type**

&#x20;   number

**Examples**

```javascript
RANDOMINT(0, 2)     // => 0 (Result can be 0, 1, or 2)
RANDOMINT(0, 100)   // => 15
RANDOMINT(0, 100)   // => 6
RANDOMINT(-10, 10)  // => -7
RANDOMINT(-10, 10)  // => -7
```

#### PICK

```javascript
PICK(array: any[])
```

Returns an random element from a given array.

**Parameters**

&#x20;   **array&#x20;*****any\[]***

&#x20;       The array.

**Return type**

&#x20;   any

**Examples**

```javascript
PICK([0,1,2])       // => 2 (Result can be 0, 1, or 2)
PICK(cities)        // => "London" (from imaginary list of cities)
```

#### PLUCK

```javascript
PLUCK(array: any[])
```

Returns an random element from a given array, **but also removes that element from it!**

**Parameters**

&#x20;   **array&#x20;*****any\[]***

&#x20;       The array.

**Return type**

&#x20;   any

**Examples**

```javascript
// Example 1:
const nums = [0, 1, 2, 3, 4];
PLUCK(nums)       // => 3
                  // nums is now [0, 1, 2, 4]

// Example 2:
let cities = ["London", "Paris", "New York", "Tokyo"];
PLUCK(cities)    // => "New York"
                 // cities is now ["London", "Paris", "Tokyo"]
```

#### RANGE

```javascript
RANGE(start: number, end: number, step?: number)
```

Creates an array of numbers in a given range.

**Parameters**

&#x20;   **start&#x20;*****number***

&#x20;       The lower limit.

&#x20;   **end&#x20;*****number***

&#x20;       The upper limit.

&#x20;   **step&#x20;*****number***

&#x20;       (optional) The step size. Defaults to 1.

**Return type**

&#x20;   number\[]

**Examples**

```javascript
RANGE(0, 2)         // => [0, 1, 2]
RANGE(2, 0)         // => [2, 1, 0]

// With step size of 2:
RANGE(0, 10, 2)     // => [0, 2, 4, 6, 8, 10]
RANGE(10, 0, 2)     // => [10, 8, 6, 4, 2, 0]
```

#### GUID

```javascript
GUID(fill?: number | string)
```

Returns a globally unique identifier (GUID). Each call will return a different GUID.

**Parameters**

&#x20;   **fill&#x20;*****number | string***

&#x20;       (optional) Value to fill the result with.

**Return type**

&#x20;   string

**Examples**

```javascript
GUID()      // => 3fc60027-b39e-43cb-8580-239a1b2b83f4
GUID()      // => 1190795d-f387-487a-8995-49394542821e
GUID(0)     // => 00000000-0000-0000-0000-000000000000
GUID(16)    // => ffffffff-ffff-ffff-ffff-ffffffffffff
GUID('a')   // => aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
```

#### EMPTYGUID

```javascript
EMPTYGUID()
```

Returns a zero-filled globally unique identifier (GUID). Equal to calling GUID(0).

**Parameters**

**Return type**

&#x20;   string

**Examples**

```javascript
EMPTYGUID()     // => 00000000-0000-0000-0000-000000000000
```

#### NOT

```javascript
NOT(boolean: any)
```

Negates the specified parameter.

**Parameters**

&#x20;   **boolean&#x20;*****any***

&#x20;       Value to be negated.

**Return type**

&#x20;   boolean

**Examples**

```javascript
NOT(true)       // => false
NOT(false)      // => true
```

#### FOR

```javascript
FOR(start: number, end: number, function: Function, step?: number)
```

Iterates over the specified range and executes the specified function for each value. Returns the number of iterations.

**Parameters**

&#x20;   **start&#x20;*****number***

&#x20;       The start value (inclusive).

&#x20;   **end&#x20;*****number***

&#x20;       The end value (inclusive).

&#x20;   **function&#x20;*****Function***

&#x20;       The function to be executed for each value.

&#x20;   **step&#x20;*****number***

&#x20;       (optional) The step value.

**Return type**

&#x20;   number

**Examples**

```javascript
FOR(1, 5, i => console.log(i))      // Will log: '1', '2', '3', '4', '5'
FOR(1, 5, i => console.log(i), 2)   // Will log: '1', '3', '5'
```

#### REPEAT

```javascript
REPEAT(count: number, function: Function)
```

Repeats the specified function the specified number of times. Returns the number of iterations.\
`REPEAT(x, func)` is shorthand for `FOR(1, x, func)`.

**Parameters**

&#x20;   **count&#x20;*****number***

&#x20;       The number of times to repeat the function.

&#x20;   **function&#x20;*****Function***

&#x20;       The function to be executed for iteration. The function will be called with the iteration number as the first parameter, starting with 1 and ending with the count.

**Return type**

&#x20;   number

**Examples**

```javascript
REPEAT(3, i => console.log(i))      // Will log: '1', '2', '3'. Note that the index starts from 1.
```

#### CLONE

```javascript
CLONE(obj: any)
```

Creates a (deep) copy of a given object.

**Parameters**

&#x20;   **obj&#x20;*****any***

&#x20;       The object to clone.

**Return type**

&#x20;   any

**Examples**

```javascript
CLONE({ a: 1, b: 'hi' })     // => { a: 1, b: 'hi' }
```

#### COERCE

```javascript
COERCE(str: any)
```

Tries to convert a string to what it represents.

**Parameters**

&#x20;   **str&#x20;*****any***

&#x20;       The string to coerce.

**Return type**

&#x20;   any

**Examples**

```javascript
COERCE('1')            // => 1 // Converted to number
COERCE('1.50')         // => 1.5 // Converted to number
COERCE('true')         // => true // Converted to boolean
COERCE('{ "a": 3 }')   // => { a: 3 } // Converted to an object
```

#### CSV2JSON

```javascript
CSV2JSON(csv: string, options?: { separator?: string, lineSeparator?: string, objects?: boolean, skipHeader?: boolean, coerce?: boolean })
```

Converts a CSV string to a JSON array. Will try to detect the separator automatically. Default newline character is '\n' - can be overriden with the 'lineSeparator' option.

**Parameters**

&#x20;   **csv&#x20;*****string***

&#x20;       The CSV string to convert.

&#x20;   **options&#x20;*****{ separator?: string, lineSeparator?: string, objects?: boolean, skipHeader?: boolean, coerce?: boolean }***

&#x20;       (optional) The options object.

**Return type**

&#x20;   { \[key: string]: any; }\[]

**Examples**

```javascript
CSV2JSON('a,b,c \n 1,2,3 \n 4,5,6') // Auto-detects the , separator
// => [{ a: 1, b: 2, c: 3 }, { a: 4, b: 5, c: 6 }]

CSV2JSON('a;b;c \n 1;2;3 \n 4;5;6') // Auto-detects the ; separator
// => [{ a: 1, b: 2, c: 3 }, { a: 4, b: 5, c: 6 }]

CSV2JSON('a,b,c \r 1,2,3 \r 4,5,6', { lineSeparator: '\r' })
// => [{ a: 1, b: 2, c: 3 }, { a: 4, b: 5, c: 6 }]

CSV2JSON('a|b|c\n1|2|3\n4|5|6', { separator: '|' }) // Specify a custom separator
// => [{ a: 1, b: 2, c: 3 }, { a: 4, b: 5, c: 6 }]

CSV2JSON('a,b,c\n1,2,3\n4,5,6', { objects: false }) // Disable parsing to objects (includes header in result too)
// => [ ['a', 'b', 'c'], [1, 2, 3], [4, 5, 6]]

CSV2JSON('a,b,c\n1,2,3\n4,5,6', { objects: false, skipHeader: true }) // Same as previous, but omits the header row
// => [ [1, 2, 3], [4, 5, 6]]
```

#### XML2JSON

```javascript
XML2JSON(xml: string, options?: { parseNumbers?: boolean, parserOptions?: any })
```

Converts an XML string to a JSON object.

**Parameters**

&#x20;   **xml&#x20;*****string***

&#x20;       The XML string to convert.

&#x20;   **options&#x20;*****{ parseNumbers?: boolean, parserOptions?: any }***

&#x20;       (optional) The options object. The property parseNumbers can be used to force numbers to be parsed as numbers. For more information on the parserOptions property [click here](https://github.com/NaturalIntelligence/fast-xml-parser/blob/96f75016ba2434006d4120517f47096c80df4081/docs/v4/2.XMLparseOptions.md).

**Return type**

&#x20;   { \[key: string]: any; }

**Examples**

```javascript
XML2JSON('<a><b>1</b><c>2</c></a>') // => { a: { b: 1, c: 2 } }
XML2JSON('<a>1</a><b>1.0</b><c>1.1</c>') // => { a: 1, b: '1.0', c: 1.1 } // Not that b is a string here
XML2JSON('<a>1</a><b>1.0</b><c>1.1</c>', { parseNumbers: true }) // => { a: 1, b: 1, c: 1.1 } // Now b is a number
```

#### JSON2XML

```javascript
JSON2XML(json: { [key: string]: any; }, options?: { builderOptions?: any })
```

Converts a JSON object to an XML string.

**Parameters**

&#x20;   **json&#x20;*****{ \[key: string]: any; }***

&#x20;       The JSON object to convert.

&#x20;   **options&#x20;*****{ builderOptions?: any }***

&#x20;       (optional) The options object. For more information on the builderOptions [click here](https://github.com/NaturalIntelligence/fast-xml-parser/blob/96f75016ba2434006d4120517f47096c80df4081/docs/v4/3.XMLBuilder.md)

**Return type**

&#x20;   string

**Examples**

```javascript
JSON2XML({ a: { b: 1, c: 2 } }) // => '<a><b>1</b><c>2</c></a>'
```

#### XLSX2JSON

```javascript
XLSX2JSON(base64file: string)
```

Converts an Excel file (base64 encoded) to a JSON object. Returns an array of sheets, each containing an array of rows, each containing an array of cells.

**Parameters**

&#x20;   **base64file&#x20;*****string***

&#x20;       The base64 encoded Excel file. Can be a data URL.

**Return type**

&#x20;   { name: string, data: any\[]\[] }\[]

**Examples**

```javascript
XLSX2JSON('data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,...')

// The above could result in something like:
//[
//    {
//        name: 'Sheet1',
//        data: [
//            ['A1', 'B1', 'C1'],
//            ['A2', 'B2', 'C2']
//        ]
//    }
//]
```
