Cut the object into several arrays according to the contents of the object

is to traverse the whole object. When args is empty, the following data is automatically saved into an array, which is divided into three arrays. How should I write clipboard.png

?
Sep.17,2021

const result = [];
list.forEach(item => {
    if (!item.args) {
        result.push([]);
    }
    result[result.length - 1].push(item);
})

here is an idea:

you can get the args empty group index

first.
const idxArr = list.findIndex((item) => {
  return !item.args
})

then in the loop of the array idxArr , each array

is fetched using the slice () method of the js array. In

lodash, there is a chunk that is simply cut into a two-dimensional array, so you can just manipulate it

.
Menu