I've got this code snippet that successfully finds the item details in an array:
var findGroupId = medias.find(medias => medias.group_name === this.groupName)
The medias
variable is an array. When I run console.log(findGroupId)
, I get this result:
https://i.stack.imgur.com/e5EXE.png
However, when I try
console.log(findGroupId.group_id)
, it returns undefined
. Interestingly, when following the example on this page under Using ES2015 arrow function and running the demo on JavaScript Demo: Array.find(), everything works perfectly.
Am I overlooking something here?
Here's a sample of the output array (retrieved from a database): https://i.stack.imgur.com/oBwi5.png PS: I'm trying to avoid using a for loop to optimize memory and time.