Home > Article > Web Front-end > Examples of using ubound function in JavaScript_javascript skills
The ubound function method in JavaScript returns the maximum index value used in the specified dimension of VBArray. How to use:
SafeArray is a required option. is a VBArray object.
dimension is optional. The dimensionality of the VBArray whose index upper bound is to be known. If omitted, ubound treats this parameter as 1.
If the VBArray is empty, the ubound method will return undefined. This method will generate a "subscript out of bounds" error if dim is greater than the dimension of the VBArray or is negative.
Example
The example below consists of three parts. The first part is the VBScript code used to create a Visual Basic safe array. The second part is the JScript code that determines the dimensions of the safe array and the upper bound of each dimension. Both parts are placed in the
section of the HTML page. The third part is the JScript code located in the section, which runs the other two parts.