慕虎7371278
function max(arr, key = 'total') { if (!Array.isArray(arr) && !arr.length) { return -1; } let index = 0, max = arr[0][key]; arr.forEach((item, i) => { let temp = item[key]; if (max < temp) { max = temp; index = i; } }); return index;}