News for hackers. Stuff that matters.
Re:Flatten Arrays in Vanilla JavaScript with Flat() and Flat... by spiralx on Wednesday January 05, 2022 @12:46PM (#29812261)
Surely the spread operator is nicer here?

    [1, 2, 3, 4, 5].reduce((acc, n) => n % 2 === 1 ? [ ...acc, 2 * n ] : acc, [])
Re:Flatten Arrays in Vanilla JavaScript with Flat() and Flat... by v413 on Wednesday January 05, 2022 @03:35PM (#29814558)
This is not efficient. Each iteration creates a new array instance due to the spread operator.
Re:Flatten Arrays in Vanilla JavaScript with Flat() and Flat... by spiralx on Tuesday January 11, 2022 @11:07AM (#29893209)
`acc.concat()` also creates a new array instance, so I don't get your point.