# Last Item

Get the last item from an array using lodash _.last

> Canonical page: https://elysiatools.com/en/tools/last-item

- **Category:** Data Processing

- **Keywords:** array, last, tail, element, lodash

## Overview

Return the final element of a JSON array.

**Highlights:**
- Uses lodash `_.last`
- Works with any data type
- Returns a JSON-formatted value

**Example:**
- Array: `["a", "b", "c"]`
- Result: `"c"`

## Inputs

- **Array** (textarea): Enter a JSON array

## When to use

- When you need to get the last element from a list in JSON data without manual indexing.
- When processing arrays in data workflows where the array length is dynamic or unknown.
- When simplifying array operations in scripts or applications to avoid off-by-one errors.

## How it works

- Input a valid JSON array into the textarea field provided.
- The tool applies the lodash _.last function to the array.
- It returns the last element as a JSON-formatted value for immediate use.

## Use cases

- Extracting the most recent entry from a time-series data array in analytics.
- Retrieving the last element in a list for pagination or navigation in web applications.
- Simplifying data processing by accessing the tail of arrays in JSON-based workflows.

## Frequently asked questions

### What does this tool do?

It returns the last item from a JSON array using the lodash _.last function.

### How do I use it?

Paste your JSON array into the input field, and the tool will output the last element instantly.

### What data types are supported?

It works with any data type in the array, such as strings, numbers, objects, or nested arrays.

### Is there a limit on array size?

No, it can handle arrays of any length, from small lists to large datasets.

### What happens if the array is empty?

It returns undefined, as there is no last element to extract.

## Related tools

- [Compact Array](https://elysiatools.com/en/tools/compact-array): Remove falsey values from array using lodash _.compact
- [Drop Items](https://elysiatools.com/en/tools/drop-items): Drop first N items from array using lodash _.drop
- [Drop Right Items](https://elysiatools.com/en/tools/drop-right-items): Drop last N items from array using lodash _.dropRight
- [Drop While](https://elysiatools.com/en/tools/drop-while): Drop items from array while predicate is true using lodash _.dropWhile
- [Fill Array](https://elysiatools.com/en/tools/fill-array): Fill array with value from start to end index using lodash _.fill
- [From Pairs](https://elysiatools.com/en/tools/from-pairs): Convert array of key-value pairs to object using lodash _.fromPairs
- [Pull Values](https://elysiatools.com/en/tools/pull-values): Remove specific values from an array using lodash _.pull
- [Sorted Unique](https://elysiatools.com/en/tools/sorted-unique): Remove duplicates from a sorted array using lodash _.sortedUniq

## Samples

- [Grafana Advanced Application Samples](https://elysiatools.com/en/samples/grafana-samples): Comprehensive Grafana samples covering advanced dashboard design, alerting configurations, data source integrations, and plugin development
- [QR Code Samples](https://elysiatools.com/en/samples/qrcode-samples): Sample QR code images for testing QR code reading and generation tools
- [D3.js Data Visualization Samples](https://elysiatools.com/en/samples/d3js-data-visualization): Comprehensive D3.js data visualization examples including charts, maps, animations, and interactive visualizations
- [Rome JavaScript Toolchain Samples](https://elysiatools.com/en/samples/rome): Rome JavaScript toolchain examples including configuration, linting, formatting, bundling, and project management
