1// Get index of object with specific value in array
2const needle = 3; // needle
3const haystack = [{ id: 1 }, { id: 2 }, { id: 3 }]; // haystack
4const index = haystack.findIndex(item => item.id === needle);
1// Get index of object with specific value in array
2const needle = 3;
3const haystack = [{ id: 1 }, { id: 2 }, { id: 3 }];
4const index = haystack.findIndex(item => item.id === needle);
1var elementPos = array.map(function(x) {return x.id; }).indexOf(idYourAreLookingFor);
2var objectFound = array[elementPos];