key-for-id

Find the key for a specific value in an array

key-for-id

Find the key for a specific value in an array

Table of Contents

Install

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

Usage

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

Contributing

Pull requests for new features, bug fixes, and suggestions are welcome!

License

MIT

HomePage

https://github.com/jxshco/key-for-id#readme

Repository

git+https://github.com/jxshco/key-for-id.git


公众号

欢迎 JavaScript 爱好者