Now note that JScript can return or receive arrays of VARIANTs only. That was the reason the the method defined is with returnVal type of VARIANT.

VARIANT var;

var.vt = VT_ARRAY | VT_VARIANT;

var.parray = psa;

*arrayVal = var;

Now story does not end here. It iseven more trickier to use this array in Jscript. The variable needs to be converted to VB array first and then we need to use toArray method on this to actually get JScript Array. Here is how: