Use VBArray in javascript (example of calling VBS in JS)

Source: Internet
Author: User
Tags javascript array

JavaScript Array Object Reference Manual
Array object
Array objects are used to store multiple values in a single variable.

Syntax for creating an Array object:
New Array ();
New Array (size );
New Array (element0, element0,..., elementn );
Parameters
The parameter size is the expected number of array elements. The returned array. The length field is set to the value of size.

Element..., elementn is the parameter list. When these parameters are used to call the constructor Array (), the elements of the newly created Array are initialized to these values. Its length field is also set to the number of parameters.

Return Value
Returns the newly created and initialized array.

If no parameter is used when the constructor Array () is called, the returned Array is empty and the length field is 0.

When a constructor is called, only one numeric parameter is passed. The constructor returns an array with a specified number and an undefined element.

When other parameters call Array (), the constructor initializes the Array with the value specified by the parameter.

When a constructor is called as a function without the new operator, its behavior is exactly the same as that when the new operator is used to call it.
Array Object Attributes

Attribute description
Constructor returns a reference to the array function that creates this object.
Index
Input
Length setting or return the number of elements in the array.
Prototype enables you to add attributes and methods to an object.
Array object Method
FF: Firefox, IE: Internet Explorer

Method description
Concat () connects two or more arrays and returns results.
Join () puts all elements of the array into a string. The elements are separated by the specified delimiter.
Pop () deletes and returns the last element of the array.
Push () adds one or more elements to the end of the array and returns a new length.
The order of elements in the array is reversed by reverse.
Shift () deletes and returns the first element of the array.
Slice () returns the selected element from an existing array
Sort () sorts array elements
Splice () deletes an element and adds a new element to the array.
ToSource () returns the source code of the object.
ToString () converts an array to a string and returns the result.
ToLocaleString () converts the array to a local array and returns the result.
Unshift () adds one or more elements to the beginning of the array and returns a new length.
ValueOf () returns the original value of the array object


The html source code is as follows: www.2cto.com

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> test </title>
<HEAD>
<Script language = "VBScript">

Function CreateVBArray ()
Dim I, j, k
Dim a (2, 2)
K = 1
For I = 0 To 2
For j = 0 To 2
A (j, I) = k
Document. writeln (k)
K = k + 1
Next
Document. writeln ("vbCRLF ")
Next
CreateVBArray =
End Function

</SCRIPT>

<Script language = "JScript">

Function VBArrayTest (vbarray ){
Var a = new VBArray (vbarray );
Var B = a. toArray ();
Var I;
For (I = 0; I <9; I ++)
{
Document. writeln (B [I]);
}
}

</SCRIPT>
</HEAD>

<BODY>
<Script language = "JScript">

VBArrayTest (CreateVBArray ());

</SCRIPT>
</BODY>
</Html>

This article is for the next javascript to get the integer array and string array returned by com.


From xt_chaoji's column

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.