is there a way to search an object instead of an array?
See original GitHub issueI’m using normalizr to get an object with the ids as keys, so I can access specific items without iterating every time through the array. I’ve seen that fuse can be configured to return only the results ids, which is nice for my purpose. But then it does not take my nested object.
Example:
const collection = {
135 : {
name : 'foo',
_id : 135
},
187 : {
name : 'bar',
_id : 187
}
}
the search always returns an empty array 😦
Issue Analytics
- State:
- Created 8 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Find a value in an array of objects in Javascript - Stack Overflow
const search = what => array.find(element => element.name === what);. And you can check whether the item was ...
Read more >How to Search in an Array of Objects with Javascript
Searching in an array of objects can be done in Javascript using a loop, Array.find() or Array.findIndex() methods.
Read more >Array.prototype.find() - JavaScript - MDN Web Docs - Mozilla
The find() method is an iterative method. It calls a provided callbackFn function once for each element in an array in ascending-index order, ......
Read more >Javascript: How to find an object in an Array of objects
The first approach would be to find the array index of the search object using Array.findIndex(). Once the search index is found, we...
Read more >Four Methods to Search Through Arrays in JavaScript
Learn about four approaches to searching for values in arrays: includes, indexOf, find, and filter methods.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @Artem-Schander 😃
Thinking more about this, it might worth implementing in the core lib.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days