var test= [
{
applytime: 1637993230077,
},
{
applytime: 1637993230077,
},
{
applytime: 1637993230078,
},
{
applytime: 1637993230078,
},
]
function checkSameData(tableData2){
let cache = {}; //存储的是键是applytime 的值,值是applytime 在indeces中数组的下标
let indices = []; //数组中每一个值是一个数组,数组中的每一个元素是原数组中相同applytime的下标
tableData2.map((item,index)=>{
let applytime = item.applytime;
let _index = cache[applytime];
if(_index!==undefined){
indices[_index].push(tableData2[index])
}else{
cache[applytime] = indices.length
indices.push([ tableData2[index]])
}
})
console.log(indices)
}
this.checkSameData(test)
网友评论