How to use blank lines of js to distinguish data

the screenshot of the data printed by the console is as follows

clipboard.png

  2`4 01,3,5
Oct.04,2021

const arr = [0, 1, null, 3, null, 5];
let result = arr.reduce((res, acc) => {
    if (acc === null) {
        res.push([]);
        return res;
    }

    res[res.length - 1].push(acc)
    return res;
}, [[]])

console.log(result);//[ [ 0, 1 ], [ 3 ], [ 5 ] ]

take a chestnut, the actual situation changes the null value judgment part to the object judgment.
then remind you not to map.


the way you pass the data in this way is inherently wrong. The normal format would look like this:
`

data: [
    {
        year: '2011',
        type: 'type1',
        name: '',
        save: '30'
    }
]

`
then traverse the array according to the type field for classification
in addition, it is true to use Chinese as the key value.

Menu