npm-indexofkey
Which receives array, (key, value) object pair and returns the index of that particular {key,value} pair in that array and also it is flexible enough to return the first index , last index and also an array of multiple indexes.
Installation
npm i npm-indexofkey
Usage
var indexOfkey = ;
getIndex(array, {key, value})
Receives the input array, (key, value) object pair and returns the first index of that particular {key,value} pair.
var indexOfkey = var inputArray = "id":null"number":7"isValid":false"number":362"isValid":true"count":126"isValid":false"number":10; indexOfkey; // 1
getIndexLast(array, {key, value})
Receives the input array, (key, value) object pair and returns the last index of that particular {key,value} pair.
var indexOfkey = var inputArray = "id":null"number":7"isValid":false"number":362"isValid":true"count":126"isValid":false"number":10; indexOfkey; // 3
getAll(array, {key, value})
Receives the input array, (key, value) object pair and returns the array of all indexes of that particular {key,value} pair.
var indexOfkey = var inputArray = "id":null"number":7"isValid":false"number":362"isValid":true"count":126"isValid":false"number":10; indexOfkey; // [1,3]
Demo
Demo @npm-array-unique | https://tonicdev.com/npm/npm-indexofkey
Author
Krishcdbry [krishcdbry@gmail.com]
Licence
MIT @krishcdbry