2.4.17.4.5 VBArray.prototype.toArray ( )

The method copies all the elements of a multi-dimensional COM SAFEARRAY into a one-dimensional ECMAScript Array instance. When called with no arguments, toArray performs the following steps:

1. Call ToObject passing the this value as the argument.

2. If Result(1) is not a VBArray instance, raise a TypeError exception.

3. Get the value of the [[SArray]] property of Result(1).

4. Let SA be the COM SAFEARRAY referenced by Result(3).

5. Let dim be the number of dimensions of the SA.

6. If dim is zero, return a new Array object that is created as if by evaluating the expression new Array(0) using the original Array constructor object.

7. Let size be the total number of array elements of SA.

8. Let A be a new Array object that is created as if by evaluating the expression new Array(size) using the original Array constructor object.

9. Access the elements of SA in row-major order and store the elements into the array indexed properties for A starting with property 0.

10. Return A