loading...

re: Javascript Array.push is 945x faster than Array.concat 🤯🤔 VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Very thorough article. Considering the fame of lodash, I now wonder is there's a place for an equivalent with performance in mind. I also wonder ...
 

Another sample is array.push vs array.unshift, basically for memory reasons. If I remember correctly, a push is simple for most computers because it already has "extra" memory allocated at the end of an array, and will only have to recreate the array when the allocated memory runs out. unshift however will always recreate the whole array because adding an item to the start of an array would require moving ever single item one step. Recreating the whole array is simpler to do than moving each one.

See stackoverflow.com/questions/440315...

 
code of conduct - report abuse