我有一系列像這樣的對(duì)象 const arrayOne = [ { id: 'call_1', callDuration: 3 }, { id: 'call_2', callDuration: 5 }, { id: 'call_3', callDuration: 4 }, { id: 'call_4', callDuration: 8 }, { id: 'call_5', callDuration: 3 }, { id: 'call_6', callDuration: 4 }, { id: 'call_7', callDuration: 6 }, { id: 'call_8', callDuration: 7 }, { id: 'call_9', callDuration: 25 }, { id: 'call_10', callDuration: 25 },];我需要從 arrayOne 中創(chuàng)建以下一個(gè): const arrayTwo = [ [ { id: 'call_1', callDuration: 3 }, { id: 'call_2', callDuration: 5 }, ], [ { id: 'call_2', callDuration: 5 }, { id: 'call_3', callDuration: 4 }, ], [ { id: 'call_3', callDuration: 4 }, { id: 'call_4', callDuration: 8 }, ], [ { id: 'call_4', callDuration: 8 }, { id: 'call_5', callDuration: 3 }, ], [ { id: 'call_5', callDuration: 3 }, { id: 'call_6', callDuration: 4 }, ], [ { id: 'call_6', callDuration: 4 }, { id: 'call_7', callDuration: 6 }, ], [ { id: 'call_7', callDuration: 6 }, { id: 'call_8', callDuration: 7 }, ], [ { id: 'call_8', callDuration: 7 }, { id: 'call_9', callDuration: 25 }, ], [ { id: 'call_9', callDuration: 25 }, { id: 'call_10', callDuration: 25 }, ],];我想要的基本上是創(chuàng)建一個(gè)包含對(duì)象的新數(shù)組。我不知道如何處理這個(gè)問(wèn)題。如果您有任何想法,請(qǐng)告訴我。
如何在 JavaScript 中從對(duì)象數(shù)組創(chuàng)建數(shù)組數(shù)組而不是分塊數(shù)組
慕尼黑的夜晚無(wú)繁華
2023-08-10 16:01:38