JS How to add elements to an array of arrays (2013-09-04 10

Source: Internet
Author: User
Tags array sort

Unshift: Adds a parameter to the beginning of the original array and returns the length of the array pop: Deletes the last item of the original array and returns the value of the deleted element, or undefined push if the array is empty: Adds the parameter to the end of the original array and returns the length of the array concat: Returns a new array, is to add parameters to the original array of splice (Start,deletecount,val1,val2,...) : Deletes the DeleteCount entry starting from the start position and inserts val1,val2 from that position,... reverse: Reverse the array sort (orderfunction): Sort by the specified parameter array slice (start,end) : Returns a new array that consists of the entries from the original array that specify the starting subscript to the end of the subscript. Details: 1, creation of the array var arrayobj = new Array (); Create an array var arrayobj = new Array ([size]); Create an array and specify the length, note not the upper limit, is the length var arrayobj = new Array ([element0[, element1[, ... [, ELEMENTN]]]); Create an array and assign a value to illustrate, although the second method creates an array that specifies the length, the array is actually variable in all cases, that is, even if you specify a length of 5, you can still store the element outside the specified length, note that the length changes accordingly. 2. Access to the elements of the array var testgetarrvalue=arrayobj[1]; Gets the element value of the array arrayobj[1]= "This is the new value"; Assigns a new value 3 to the array element, adding arrayobj to the array element. Push ([Item1 [item2] [... [Itemn]]); /Adds one or more new elements to the end of the array and returns the new length of the array arrayobj.unshift ([Item1 [ITEM2 [... [Itemn]]); /Add one or more new elements to the beginning of the array, the elements in the array are automatically moved back, returning the new length of the array arrayobj.splice (insertpos,0,[item1[, item2[, ...) [, Itemn]]]); /inserts one or more new elements into the specified position of the array, the element at the insertion position automatically moves back, and returns "". 4, the deletion of the array elements arrayobj.pop (); Removes the last element and returns the element value Arrayobj.shift (); Removes the first element and returns the element value, and the elements in the array are automatically moved forward arrayobj.splice (Deletepos,deletecount); Removes the specified number of DeleteCount elements from the specified position, Deletepos, and returns the removed element 5, The Intercept and merge Arrayobj.slice of the array (start, [end]); Returns the part of the array as an array, noting that the end corresponding element is not included, and if omit end copies all elements after start arrayobj.concat ([item1[, item2[, ... [, Itemn]]]); Concatenate multiple arrays (which can also be strings, or a mixture of arrays and strings) into an array, returning the concatenated new array: WWW.MLS169.COM6, copy of array arrayobj.slice (0); Returns a copy array of the array, noting that it is a new array, not pointing to Arrayobj.concat (); Returns a copy array of the array, note that it is a new array, not a pointer to 7, the array element's sort arrayobj.reverse (); Reverses the element (the top row to the last, the last row to the top), and returns the array address Arrayobj.sort (); Sorts the array elements, returning the arrays address 8, the array elements of the string arrayobj.join (separator); Returns a string that connects each element value of an array, separated by separator. toLocaleString, toString, valueOf: Can be seen as a special use of joins, not commonly used

JS How to add elements to an array of arrays (2013-09-04 10

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.