Check if array of objects contains

Last update in 8/2019

Let's say you have some object data in array similar to this.

const users = [
{
name: 'John',
email: 'john@gmail.com',
},
{
name: 'Bartol',
email: 'b@bartol.dev',
},
]

And you want do something only for user with specific name.

if (users.some(e => e.name === 'Bartol')) {
// do something
}

Resources #