// Sample array
var myArray = [
{"id": 1, "name": "Alice"},
{"id": 2, "name": "Peter"},
{"id": 3, "name": "Harry"}
];
// Get the Array item which matchs the id "2"
var result = myArray.find(item => item.id === 2);
console.log(result.name); // Prints: Peter
// Get the index of Array item which matchs the id "2"
var index = myArray.findIndex(item => item.id === 2);
console.log(index); // Prints: 1
console.log(myArray[index].name); // Prints: Peter