I have the following array of objects:
[
{
"id": 1,
"name": "Leanne Graham",
"username": "Bret",
"email": "[email protected]",
"phone": "1-770-736-8031 x56442",
"website": "hildegard.org",
},
{
"id": 2,
"name": "Ervin Howell",
"username": "Antonette",
"email": "[email protected]"
"phone": "010-692-6593 x09125",
"website": "anastasia.net"
},...];
I am passed id as 2. I want the index of array of objects where id=2. How can this be done in javascript or jQuery?