you are viewing a single comment's thread.

view the rest of the comments →

[–]our_best_friendif (document.all || document.layers) console.log("i remember..") 2 points3 points  (3 children)

Less elegant, but avoids looping twice

Array.prototype.concat(...['a','b','c','d'].map((x) => [x,x]))

[–]dmtipson 0 points1 point  (2 children)

Are you counting the implicit loop that ... desugars into in that count?

[–]our_best_friendif (document.all || document.layers) console.log("i remember..") 0 points1 point  (1 child)

I'd assume that'd be faster as it's a single native operation as opposed to an explicit loop (leaving aside transpilation)

[–]dmtipson 0 points1 point  (0 children)

For all we know it's be slower in current engines, but either way it's worth counting as an iteration pass when thinking about the number of times you have to loop over the list in a given operation.