"what if we just .push elements individually?"
it depends! in some cases this is even faster than array1.push(...array2)
array1.push(...array2)
plus it is not limited by max call stack size = ~100K in chrome, 500K in firefox
Array.prototype._pushArray = function (other) { for (var i = 0; i < other.length; i++) this.push(other[i]); return this; }; array1._pushArray(array2)._pushArray(array3)._pushArray(array4);
should be the fastest, simplest and most robust solution
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
"what if we just .push elements individually?"
it depends!
in some cases this is even faster than
array1.push(...array2)
plus it is not limited by max call stack size = ~100K in chrome, 500K in firefox
should be the fastest, simplest and most robust solution