# Nth Item

Get the item at a specific index using lodash _.nth

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

- **Category:** Data Processing

- **Keywords:** array, nth, index, element, lodash

## Overview

Return the item at a specific index in the array.

**Highlights:**
- Uses lodash `_.nth`
- Supports negative indices (counting from the end)
- Returns a JSON-formatted value

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

## Inputs

- **Array** (textarea): Enter a JSON array
- **Index** (number): Zero-based index (negative counts from the end)

## When to use

- When you need to extract a specific element from an array by its position.
- When working with arrays where negative indices are useful for counting from the end.
- When you want a quick, reliable way to access array elements without writing custom code.

## How it works

- Input a valid JSON array in the 'Array' field.
- Specify the index (zero-based, negative for reverse counting) in the 'Index' field.
- The tool uses lodash _.nth to fetch the item and outputs it as a JSON-formatted value.

## Use cases

- Extracting the last item from a list of logs or records for quick review.
- Accessing a specific element in an array of configuration settings during automation.
- Simplifying data extraction in scripts where array indices are dynamically determined.

## Frequently asked questions

### What does a negative index mean?

A negative index counts from the end of the array, where -1 is the last element.

### What happens if the index is out of bounds?

The tool returns undefined for indices beyond the array length.

### Can I use this with nested arrays or objects?

No, it works on a single-level array; for nested structures, use other data processing tools.

### Is the index zero-based?

Yes, indices start at 0 for the first element, and negative indices count from the end.

### What input format is required?

The array must be valid JSON, such as ["a", "b", "c"], and the index must be a number.

## Related tools

- [Get Path](https://elysiatools.com/en/tools/get-path): Get a value at a path using lodash _.get
- [Group By](https://elysiatools.com/en/tools/group-by): Group items by a derived key using lodash _.groupBy
- [Head Item](https://elysiatools.com/en/tools/head-item): Get the first element of array using lodash _.head
- [Index Of](https://elysiatools.com/en/tools/index-of): Find the index of a value in array using lodash _.indexOf
- [Initial Items](https://elysiatools.com/en/tools/initial-items): Get all elements except the last using lodash _.initial
- [Remove By Predicate](https://elysiatools.com/en/tools/remove-by-predicate): Remove items that match a predicate using lodash _.remove
- [Sorted Index](https://elysiatools.com/en/tools/sorted-index): Find the insertion index in a sorted array using lodash _.sortedIndex
- [Tail Items](https://elysiatools.com/en/tools/tail-items): Return all but the first array item using lodash _.tail

## 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
