Correctly handle lastObject / lastItem if the array is empty.