Find the key for a specific value in an array
- Quick start
Add key-for-id to your project using npm or yarn.
Install (NPM):
$ npm install key-for-id --save
Install (Yarn):
$ yarn add key-for-id
Import KeyForID into Your Project
import KeyForID from 'key-for-id'
Pass An Array as the first parameter, the key as the second and the value your searching for as the third.
let people = [{name: 'Josh'}, {name: 'Steven'}, {name: 'Sarah'}]
let index = KeyForID(people, 'name', 'Sarah') // 2
Pull requests for new features, bug fixes, and suggestions are welcome!