How to access an object from among the objects of an array?
like this :
const users = [
{ id: 1, name: "John" },
{ id: 2, name: "David" },
{ id: 3, name: "Marie" },
];
How to access the object by name or …?
>Solution :
you can use like this:
const john = users.find(item => item.name === 'John');
alert(john.id); // 1