現(xiàn)在有個(gè)數(shù)組:現(xiàn)在要算出第一條數(shù)據(jù)和第二條數(shù)據(jù)的時(shí)間差,第二條和第三條的時(shí)間差,以此類推,后面還有很多條數(shù)據(jù),不固定 historyList: [{
id:1,
date:'2019-01-18 14:08'
},{
id:2,
date:'2019-01-19 14:08'
},{
id:3,
date:'2019-01-20 14:08'
}]我寫到這里沒有思路了:不知道該怎么取出相鄰兩項(xiàng)來相減?if (ctx.historyList.length > 1) {
ctx.historyList.forEach((item, index) => { console.log(ctx.historyList[index].date)
})
}
循環(huán)數(shù)組里的相鄰項(xiàng),數(shù)據(jù)怎么相減
慕容森
2019-02-03 23:01:50