Is there any way to performantly merge one array into another in Javascript?
2
1kṀ600
Oct 13
45%
chance

I have spent a while looking and it appears the answer is no. But maybe there's some low-level API that makes it possible?

For "performant" let's say at least as fast as Array.concat, since that's an existence proof that JS's general data model is capable of handling this sort of thing that quickly.

Resolves NO if no one provides such a way before close.

Get
Ṁ1,000
to start trading!
Sort by:

Does [...a, ...b] count?

@NayutaIto That creates a new array, it does not add one to the other. It's also about 5x slower than Array.concat, so I don't know why I would ever want to use it for that task either.

What does "performantly" mean here?

...for that matter, what does "merge" mean? Do you want to combine two sorted arrays into a single large sorted array? Or just concatenate two arrays?

@jcb Let's say it needs to be at least as fast as Array.concat.

© Manifold Markets, Inc.TermsPrivacy