Returns the last item of an array.
lastItem([1, 2, 3]); // 3lastItem([]); // undefined Copy
lastItem([1, 2, 3]); // 3lastItem([]); // undefined
The item type.
The source array type.
The array.
The last item of the array. If the array is empty, undefined is returned.
undefined
Returns the last item of an array.
Example