let detectionCycleList = [“2020-01-01”,“2020-01-02”,“2020-01-03”]; //日期数组
let newArr = detectionCycleList.map(ele =>{
return new Date(ele).getTime()
})
let minIndex = 0;
let minDate = newArr[0];
let maxIndex = 0;
let maxDate = newArr[0];
newArr.forEach((ele,index) => {
if(ele < minDate) {
minDate = ele;
minIndex = index;
}
if(ele > maxDate) {
maxDate = ele;
maxIndex = index;
}
})
//以下打印的就是最大日期和最小日期
console.log(11111, detectionCycleList[minIndex], detectionCycleList[maxIndex])
