News for hackers. Stuff that matters.
Re:Avoid Using New Array() in JavaScript by DXA9zE on Sunday May 24, 2020 @01:14AM (#23289303)
There is nothing wrong with using new Array() to construct array of known capacity. By default, I think JS literal arrays will have a capacity of 4, so especially if you know you will have less than four elements, or a non power of two number of elements, this can be seen as a micro-optimization. `bluebird` uses new Array() extensively, e.g.

https://github.com/petkaantonov/bluebird/blob/12154adb501660...

Re:Avoid Using New Array() in JavaScript by akully on Saturday May 23, 2020 @08:01PM (#23287796)
I first heard this from Doug Crockford, a senior architect for Javascript

+1 for the corroboration

Re:Avoid Using New Array() in JavaScript by yogiUSA on Saturday May 23, 2020 @08:04PM (#23287815)
Thank you!

I was going through the differences and it started acting weirdly so I thought let's share this.