javascript - Are there any downsides of using an in-place concat? -


sometimes i'm annoyed memory requirements array.prototype.concat since it's not done in-place , returns new array instead of concatenating array passed in argument instance concat called on, name logically imply.

assuming cooperating other libraries not issue, there downside (performance, decreased length limit, etc.) of re-implementing so?

array.prototype.concat = function (array) {     this.push.apply(this, array);      return this; }; 

conversely, alternative implementation decrease auxillary memory usage o(1), or internal mechanism keep @ o(n)?


Comments