Skip to main content
8 events
when toggle format what by license comment
Dec 26, 2016 at 13:36 history edited Nenad Vracar CC BY-SA 3.0
added 135 characters in body
Dec 26, 2016 at 13:31 comment added Bergi Because only arrays should be passed to concat. Plain values kinda work as well, but concat always has to check whether they are spreadable like arrays (which since ES6 is also not exactly the same any more)
Dec 26, 2016 at 13:28 comment added Nenad Vracar @Bergi Wow that is great, just why brackets on : [e] how about data.reduce((r, e) => r.concat(Array.isArray(e) ? flat(e) : e), [])?
Dec 26, 2016 at 13:11 comment added Bergi Btw, in the case of concat you don't need to reassign r. Better just use (r, e) => r.concat(Array.isArray(e) ? flat(e) : [e]) as the reducer.
Dec 26, 2016 at 13:10 comment added Bergi s/can/should/ use reduce. If you want imperative iteration, use a for…of loop instead of forEach with an arrow function.
Dec 26, 2016 at 11:59 comment added Rajesh Dixit && r will kill readability. I'm sure many people will not understand purpose of it. I'd suggest splitting code into 2 lines and using return r instead
Dec 26, 2016 at 11:56 history edited Nenad Vracar CC BY-SA 3.0
added 446 characters in body
Dec 26, 2016 at 11:49 history answered Nenad Vracar CC BY-SA 3.0