-
Notifications
You must be signed in to change notification settings - Fork 0
indexFirstN(arrayObject,n,query)
Bhumil Sarvaiya edited this page Aug 31, 2017
·
1 revision
The function will return array of index of first n objects in array which satisfy the query passed.
If the number of objects in array satisfying the query is p which is less than n, then it will return array of index of first p objects in array that satisfy the query
If no object satisfy the condition, null will be returned.
var daex = require('json-daex')
var obj = [
{
name: 'abc',
type: 'array',
age: 20
},
{
name: 'pqr',
type: 'string',
age: 20
},
{
name: 'xyz',
type: 'array',
age: 22
},
{
name: 'ghi',
type: 'array',
age: 20
},
{
name: 'mno',
type: 'number',
age: 20
}
]
console.log(daex.indexFirstN(obj,{'type':'array'},2))
//get index of first 2 objects with type: array
// Output: [ 0, 2 ]