Skip to content
Advertisement

How to check if array of objects that contains another array of object has property

Hi I have an array of objects which contains another array of objects. I need to find an object in array which contains another object in it’s array with certain propery ID. Let’s say i need to find an object in casses array which contains a user with certain ID. ID for user is unique.

JavaScript

I could use a nested loops and so on. But i wondering is it possible to do with one line ? Something like this but one level deeper:

JavaScript

Advertisement

Answer

Assume your case with ID set to “3”

Try below

JavaScript
Advertisement