Two problems of array reduce in js to solve

1. Three arrays
[1Jing 2 code 3], [4 Jing 5], [6 Jing 7]
expands into
145147156157246

2. Array objects
[{name:"a",children: [{name:"a-1"}]}, {name:"b",children: [{name:"b-1"}]}]
expand to
[{name:"a"}, {name:"a-1"}, {name:"b-1"}]

Apr.07,2021

the first one on GitHub seems to have the same function (nothing to do with reduce , but the logic is the same): https://github.com/Jiasm/note.

the second operation looks like this, if you have to use reduce :

const a = (1, 2, 3, 4, 5) // a === 5

so what your code means is to put the element in an array and then return the array, and you can simply understand that line of expression as code like this:

results.push(XXX)
return results
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b38888-2c12a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b38888-2c12a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?