JavaScript Array API Simple description

Source: Internet
Author: User
Tags javascript array

1, an array plus another (some) array, will not modify the original array will only return the new array

Arrayobject.concat (Arrayx,arrayx,......, Arrayx)

2, separates the array according to the specified string, does not modify the original array will only return the new array

Arrayobject.join ("string")

3, delete and return the last element, will modify the original array

Arrayobject.pop ()

4, add one or more elements to the end of the array, and return the new length, will modify the original array

Arrayobject.push (Newelement1,newelement2,...., newelementx)

5. The order of the array elements of the original array is reversed, and the original array is modified

Arrayobject.reverse ()

6. Remove the first element from the array and return the first element, modify the original array

Arrayobject.shift ()

7, starting from the first few (start) to select how many (end), do not modify the original array

Arrayobject.slice (Start,end)

8, the elements of the array to sort, will modify the original array

Arrayobject.sort (SortBy)//sortby indicates the name of the function
function Sortnumber (A, b) {return a-b}//from small to large sort function sortnumber (A, b) {return b-a}//from large to small sort

9, starting from the number of the array (index), delete how many (Howmany), add what Element (item1,....., ItemX)

Arrayobject.splice (index,howmany,item1,....., ItemX)

10, add one or more elements from the beginning of the array, and return the new length, modify the original array

Arrayobject.unshift (Newelement1,newelement2,...., newelementx)

11, set a function, the array of each number in the function of the method, do not modify the original array, fun for the Set function method

function Fun (num) {  return Num++}arrayobject.map (fun)

JavaScript Array API Simple description

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.