两个对象为一组(常用于广播)
let obj = [
{
loginAccount: "13018885465",
title: "用户已注册",
},
{
loginAccount: "13018885465",
title: "ddd",
},
{
loginAccount: "13018885465",
title: "aaa",
},
{
loginAccount: "13018885465",
title: "bbb",
}
]
let item = [];
let recentlyUpdated = [];
let arr = [];
let index = obj.length;
item = obj
for(let i = 0; i < item.length; i++){
arr.push(item[i])
if(i != 0 && (i == 1 || ((i+1)%2 == 0 && i > 1))){
recentlyUpdated.push(arr)
arr = [];
}
}
if(arr.length > 0){
recentlyUpdated.push(arr)
}
console.log(recentlyUpdated)