I have the following array:
var usuarios = [
{nome: "João", id: 1},
{nome: "Maria", id: 2},
{nome: "José", id: 3},
{nome: "Ana", id: 4},
];
I need to return the user index José. I tried using indexOf as follows:
var usuarios = [
{nome: "João", id: 1},
{nome: "Maria", id: 2},
{nome: "José", id: 3},
{nome: "Ana", id: 4},
];
console.log(usuarios.indexOf({nome: "José", id: 3}))
But it is returned -1. I know it's possible to do this with for (), but is it possible to do with indexOf?