RE: How to Find an Object Key Value Inside an Array
Hi, does anyone know how to find an object key value inside an array? For instance, if I have an array of objects called records.
var records = [{
id: 12345
type: transaction
}]
If I want to check this array to see if there’s an object that contains the ID “12345”, how would I do that? Is there a way without looping through the whole array? I know I can use the array.includes method to find a value inside a regular array. But that doesn’t seem to work because I’m looking for an object key value inside an array.
Also, if you load the lodash library in, you can use the _.find function. In general, that whole library can be very useful.