Skip to content

Latest commit

 

History

History
30 lines (20 loc) · 793 Bytes

arrayLast.md

File metadata and controls

30 lines (20 loc) · 793 Bytes

Back to reference

arrayLast(arr, ignoreEmpty = false)

Returns the last element of an array arr. if ignoreEmpty is set to false (default value), the last element in the array can be null, undefined or "". If ignoreEmpty is set to true, it returns the last element in the array that is not null, undefined or "".

Example:

If you have an array like this:

const someNumbers = [1, 2, 3, 4, 5, null];

This will return the last element in someNumbers, which is null in this case:

let last = gmynd.arrayLast(someNumbers);

// null

Whereas this will return the last element in someNumbers, which is not "empty" (5 in this case):

let last = gmynd.arrayLast(someNumbers, true);

// 5