by staeke · 7y ago · 0 comments
const all = [[1,2,3,4,5], [1,2,3,4,5], ...] //15000 items
let ret = [];
for (item of all) {
ret = ret.concat(item);
// Or ret.push(...item);
}
The point of using concat is of course that you don't have to do the loop. You're shuffling bytes for no use like crazy there. Not concat's fault. You should be doing: [].concat(...all);
This runs in ~1ms on my machine (latest Chrome). Custom versions, and loop + push both come it at around ~4ms.No comments yet.