DEV Community

Discussion on: Populating a pre-allocated array slower than a pushing to a regular array?

Collapse
 
alainvanhout profile image
Alain Van Hout

There seems to be some variation between browsers, with Chrome being the odd one out: blog.scottlogic.com/2010/10/15/jav...

Collapse
 
henryjw profile image
Henry Williams

Thanks for sharing. My assumption is that this behavior is in the V8 engine that Chrome runs. The tests I shared were executed in Node.js, but I see similar behavior in Edge (Chromium version) and Chrome.

I think that optimization makes sense since using .push() is probably a more common way of building an array in web applications.