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.
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.
There seems to be some variation between browsers, with Chrome being the odd one out: blog.scottlogic.com/2010/10/15/jav...
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.