编辑代码

//JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。 
function splitListByTime5(list) {
    const arr = []
    let i = 0
    arr[i] = []
    list.forEach((element, index) => {

        const now = new Date(element.updateAt).getTime()
        const next = index < list.length - 1 ? new Date(list[index + 1].updateAt).getTime() : now
        if (next - now > 5 * 1000 * 60) {

            i = i + 1
            arr[i] = []
        }
        arr[i].push(element)
    })
    console.log(arr)
}

const list = [

    { updateAt: '2021-07-01 08:01' },
    { updateAt: '2021-07-01 08:02' },
    { updateAt: '2021-07-01 08:03' },
    { updateAt: '2021-07-01 08:09' },
    { updateAt: '2021-07-01 08:10' },
    { updateAt: '2021-07-01 08:19' },
    { updateAt: '2021-07-01 08:23' }

]
// splitListByTime5(list)
function test(list) {
    const arr = []
    let i = 0
    arr[i] = []
    list.reduce((a, b, index) => {
        const now = new Date(a.updateAt).getTime()
        const next = new Date(b.updateAt).getTime()
        if (next - now > 5 * 1000 * 60) {
            i = i + 1
            arr[i] = []
        }
        arr[i].push(a)
    })
     console.log(arr)
}
//test(list)