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 ""
.
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