Array method
Empty array
1:arr.length=0
2:arr=[]
Arr.push ()//to the last element of the array, a return value will be added, which is the new array length
Arr.unshift ()//To add an element to the first array, and also return a new array length
IE6 7 does not support Unshift return value
Arr.pop ()//delete the last element, return the deleted element
Arr.shift ()//delete the previous element, return the deleted element
arr.splice//Delete, replace, add
Arr.splice (0,1)//delete one from the beginning of 0
Arr.splice (0,2,3)//with a third substitution starting from zero two
Arr.splice (1,0,3)//
Add 3 to the 1 position
Array de-weight? bugs
for (var i=0; i<arr.length; i++) {
for (Var j=i+1;j<arr.length-1;j++) {
if (Arr[i]==arr[j]) {
Arr.splice (j,1)
j--
}
}
}
Array sorting
Arr.sort ()//Arrange By string
Arr.sort (function (b) {
Return a-b;//from small to large
Return b-a;//from large to small
})
Random sort
Arr.sort (function (b) {
Return Math.random ()-0.5
})
Mathematical Methods
Math.Round ()//rounding
Math.random ()//0~1 random number
Math.ceil ()//Upward value
Math.floor ()//down-fetch value
Arr1.concat (ARR2,ARR3)
Stitch the array together
Arr.reverse ()
Reverse array Order
Array Iteration Method
Arr.foreach (function (e) {Console.log (1)})
JS Array method