Summary of usage of handling arrays

Source: Internet
Author: User

A good way to add a new array of weight

[].filter, ' A ', 1, ' a ',

(Ele,index,array) =>{return index===array.indexof (Ele)}

)

Serial Number Method function usage whether the original array is affected
1 unshift Add content in front of array arr.unshift() Is
2 push Add content after the array arr.push() Is
3 shift Delete the first element of an array arr.shift() Is
4 pop Delete the last element of an array arr.pop() Is
4 splice You can add, delete, and change any position in the array. arr.splice(start,length,newItem) Is
5 slice Intercepts the array at the specified position (contains the start without ending position) arr.slice(start,end) Whether
6 concat Stitching arrays/Merging arrays arr.concat() Whether
7 reverse Reverse Array arr.concat() Is
8 sort Sort an array by encoding arr.sort() Is
9 toString Convert an array to a string arr.toString() Whether
10 join Convert an array to a string arr.join(‘指定分隔符‘) Whether

About sort: From small to large array: sort (function (A, b) {return-A-b}); Sort arrays from large to small: sort (function (A, b) {return b-a});

Copy array: sort (0); Concat ();

Summary of usage of handling arrays

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.