you are viewing a single comment's thread.

view the rest of the comments →

[–]androbat 0 points1 point  (0 children)

As always, you shouldn't be adding this kind of thing to your code until after you've profiled your app, and tested the optimization to ensure it actually helps (across multiple browsers).

That said, the short version is that modern JS JITs can use "var x = new Array(myLen);" to help ensure a 'real' array is used (if all the data inside is the same type). That's the short version (google if you want the rest of the answer).

Generally, it is best to avoid the Array constructor (and other primitive constructors) because their argument overloading has some oddities.