2018-06-17 Array

Source: Internet
Author: User

Definition of the array: ①var arr=new Array (xx,xx,xx); ②var Arr=[yy,yy,,yy];

View of the array: arr[x];

Modification of the array: arr[x]=xx;

Traversal of the array: ①for loop ② (for...in loop) for (Var i in arr) {Arr[i]};

The length of the array: arr.length; (the total number of elements in the array)

Array method: Arr.pop () Delete the last element

Arr.push () Adds an element at the end of the array

Arr.shift () Delete the first element

Arr.unshift () Adds an element to the front of the array

!!! All of the above methods change the original array

Arr.join ('-') joins an array with '-' to make it a string

Arr3=arr1.concat (ARR2) joins array 3 as array

Arr.slice (A, B) will array arr, intercept from A to B (does not contain B.) does not change the original array

Arr.splice (A, b) ditto, but change the original array

Arr.sort (); the sort of an array is sorted by the first value of the number, not by the size of the numeric value!

2018-06-17 Array

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.