javascript get index of object with value in array
// Get index of object with specific value in array
const needle = 3;
const haystack = [{ id: 1 }, { id: 2 }, { id: 3 }];
const index = haystack.findIndex(item => item.id === needle);
const index = array.findIndex((param)=> param.name == "jimmy")
/* param will iterate on every value of the array looking for
that one element that fits the criteria that is indicated in arrow function
besides it */
$scope.indexOfField = function(fieldId) {
var fieldData = $scope.model.fieldData,
i = 0, ii = $scope.model.fieldData.length;
for(i; i < ii; i++) if(fieldData[i].Id === fieldId) break;
// use i
}