LastArrayElement

Returns the last element of an array. If the value passed is not an array, it returns the original value that was passed.

javascript · Filters And Transformers

Details

IDLastArrayElement
Languagejavascript
From Version5.0.0
Tagsgeneral transformer entirelist

README

Returns the last element of an array. If the value passed is not an array, it returns the original value that was passed.

Script Data


Name Description
Script Type python3
Tags general, transformer, entirelist
Cortex XSOAR Version 5.0.0

Inputs


Argument Name Description
value An array for which to return the last value.

Outputs


There are no outputs for this script.

let value = args.value;

if (Array.isArray(value) && value.length > 0) {
    value = value[value.length - 1];
}
if (value === null) {
    value = [];
}

return value;