In terms of raw compute time JS is actually significantly slower than VBA. However this largely depends on the algorithm you use.
If we are trying to build an array with 50000000, then it is significantly faster for VBA to do than JS. However if we are to produce an array of any number of items ( 1 to n ) VBA becomes incredibly slow.
The results on my computer are listed below.
VBA fixed size long array: 0.00933219999933 seconds
VBA fixed size variant array: 0.01075579999815 seconds
JS dynamic size variant array: 0.03299999999953 seconds
VBA Collection: 0.10702589999709 seconds
VBA dynamic size long array: 0.60271329999886 seconds
VBA stdArray: 7.95831580000231 seconds
VBA dynamic size variant array: 8.36757760000182 seconds
A note on terminology:
___ Size
Here the options for ___
are fixed, dynamic and hybrid. A dynamic size array will change it's length when items are added to it. A fixed size array will only define its size at the beginning and will never be redefined thereon. Hybrid sized arrays redefine their size in batches to get the best of both worlds. In general in VBA hybrid arrays are prefferable. A hybrid array requires seperate tracker variables to track length etc.
___ array
Here the options for ___
are data types. E.G. Variant, Long, Object, Double, ... Typically (as shown) variant arrays are significantly slower than long arrays.