Array native type Extension

Source: Internet
Author: User
• 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 >

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.