allDamages.scratch.length -1
returns the last index for that array.
Edit:
allDamages.scratch.slice(-1).pop()
returns the last array item.
And if you just want to remove the last item in your array you should (like Givi said) use the pop()
method on a sorted array like so:
allDamages['scratch'].pop()
Edit2:
Because the question wasn't clear for me. This is my final shot at the problem.
var allDamagesInOneArray = [];
for(array in allDamages){
allDamagesInOneArray.concat(array);//Assuming every key is an array
}
allDamagesInOneArray.sort(function(a,b){
return a.index - b.index;
});
var lastObj = allDamagesInOneArray.slice(-1).pop(); //element with latest index