• All static methods
-To be compatible with other class libraries (prototype)
• Provides some common methods
• Provides method names with good Semantics
• Most methods are simple Encapsulation
• Array. enqueue (array, item ):
-"Inbound queue" Operation: add the item to the end of array.
• Array. dequeue (array ):
-The "out queue" Operation returns and deletes the first element of array.
• Array. addrange (array, items ):
-Add all elements in the items array to the end of the array.
• Array. Contains (array, item ):
-If array contains the item element, true is returned; otherwise, false is returned.
• Array. Clear (array ):
-Clear all elements in array.
• Array. insert (array, index, item ):
-Insert the item to the position marked as index in the array.
• Array. Remove (array, item ):
-Remove the item element from array.
• Array. removeat (array, index ):
-Remove the element whose subscript is index from array.
• Array. Clone (array ):
-Returns a new array that is the same as array.
• Array. parse (value ):
-Converts the JSON string representing the array into an array object.
• Array. indexof (array, item, start ):
-Obtain the subscript of an item in the array, starting from the subscript start. If the array does not contain the item element,-1 is returned.
• Array. Add (array, item ):
-Add item to the end of array. It is actually the same function as array. enqueue.
• Array. foreach (array, method, instance ):
-This reference uses instance as the context. Each element in array is used as a parameter and the method is called cyclically.
Use the array. foreach Method
Aspx < Form ID = " Form1 " Runat = " Server " >
< ASP: scriptmanager ID = " Scriptmanager1 " Runat = " Server " />
< Script Language = " Javascript " Type = " Text/JavaScript " >
Function Method (ELT, index, array)
{
This . Result + = " [ " + Index + " . " + ELT + " ] " ;
}
VaR items = " I am Jeffrey Zhao " . Split ( " " );
VaR OBJ = {Result: "" };
Array. foreach (items, method, OBJ );
Alert (obj. Result );
</ Script >
</ Form >