3 ms·
If you think a misunderstanding may be afoot, let me be as explicit as possible. I do not believe that moving from: a = a.concat(b) To: a = [...a, ...b] Wou
by braythwayt 7y ago
If you think a misunderstanding may be afoot, let me be as explicit as possible. I do not believe that moving from:
a = a.concat(b)
To:
a = [...a, ...b]
Would give the same performance gains as moving to:
a.push(...b)
Because [...a, ...b] creates a new array, and copies the elements of both a and b into it.
Old-timers will say that we had this exact same conversation about Java and strings way back in the day. Using a StringBuffer was faster for this kind of thing up and until Java started detecting when your use of string catenation could be replaced by a StringBuffer.