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