const myArray = [[{ id: 1, value: '1' }, { id: 1, value: '1' }, { id: 2, value: '2' }, { id: 2, value: '2' }, { id: 3, value: '3' }, { id: 1, value: '1' }], [{ id: 1, value: '1' }, { id: 1, value: '1' }, { id: 2, value: '2' }, { id: 2, value: '2' }, { id: 3, value: '3' }, { id: 1, value: '1' }]]
const bb = []
console.log(myArray)
myArray.forEach((el, i) => {
for (const k in el) {
for (const L in el) {
if (el[k].id === el[L].id) {
if (!bb[parseInt(i)]) bb[parseInt(i)] = []
if (!bb[parseInt(i)][parseInt(k)]) bb[parseInt(i)][parseInt(k)] = []
bb[parseInt(i)][parseInt(k)].push({ ...el[L] })
}
}
}
})
console.log(myArray)
console.log(bb)