# Index Of

Find the index of a value in array using lodash _.indexOf

> Canonical page: https://elysiatools.com/en/tools/index-of

- **Category:** Data Processing

- **Keywords:** array, index, search, find, lodash, position

## Overview

Find the index position of a specific value within an array.

## Features:
- Searches for a value and returns its index
- Returns -1 if the value is not found
- Supports various data types (numbers, strings, objects)
- Optional starting position for search
- Uses lodash _.indexOf for reliable searching

## Examples:
- Array: [1, 2, 3, 2], Value: 2 → Index: 1
- Array: ["a", "b", "c"], Value: "b" → Index: 1
- Array: [1, 2, 3], Value: 4 → Index: -1 (not found)
- Array: [1, 2, 3, 2], Value: 2, FromIndex: 2 → Index: 3

## Use Cases:
- **Position Finding**: Locate where an element appears
- **Duplicate Detection**: Find multiple occurrences
- **Validation**: Check if a value exists in an array
- **Data Analysis**: Analyze element positions

## Inputs

- **Array Input** (textarea): Enter a valid JSON array to search in
- **Search Value** (text): Enter the value to find (for objects/arrays use JSON format)
- **From Index** (number): Optional: Start search from this index

## When to use

- When you need to locate the exact position of an element in an array.
- To detect duplicate values by finding multiple occurrences in data.
- For validating whether a value exists in a dataset before processing.

## How it works

- Input a valid JSON array and the value you want to search for.
- Optionally specify a starting index to begin the search from a specific position.
- The tool uses lodash _.indexOf to scan the array and return the index.
- If the value is not found, it returns -1 to indicate absence.

## Use cases

- Finding the position of a specific item in a list for quick reference.
- Identifying duplicate entries in data arrays during analysis.
- Checking for the presence of a value in a collection before operations.

## Frequently asked questions

### What does the tool return if the value is not in the array?

It returns -1 to indicate the value was not found.

### Can I search for objects or nested arrays?

Yes, it supports various data types including objects and arrays, but ensure inputs are in valid JSON format.

### How do I use the fromIndex option?

Enter a number to start the search from that index, skipping earlier elements in the array.

### Is there a limit on array size?

The tool can handle arrays of any size, but performance may depend on your browser for very large datasets.

### What format should the array input be in?

The array must be entered as a valid JSON array, such as [1, 2, 3] or ["a", "b", "c"].

## Related tools

- [Find Key](https://elysiatools.com/en/tools/find-key): Find the first matching key using lodash _.findKey
- [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
- [Initial Items](https://elysiatools.com/en/tools/initial-items): Get all elements except the last using lodash _.initial
- [Intersection Arrays](https://elysiatools.com/en/tools/intersection-arrays): Find common values across multiple arrays using lodash _.intersection
- [Nth Item](https://elysiatools.com/en/tools/nth-item): Get the item at a specific index using lodash _.nth
- [Remove By Predicate](https://elysiatools.com/en/tools/remove-by-predicate): Remove items that match a predicate using lodash _.remove

## 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
- [ELK Stack Log Analysis Samples](https://elysiatools.com/en/samples/elk-stack-samples): Comprehensive ELK Stack (Elasticsearch, Logstash, Kibana) samples for log aggregation, processing, and visualization in distributed systems
- [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
