Definition form:
var arr1 = new Array (1, 5, 8, 7, 2, 10); Defines an array with 6 of data
var arr2 = new Array (); It simply defines an array (name), but does not give the value (data), which is now empty
var arr3 = [1, 5, 8, 7, 2, 10]; With ARR1, it is just a shorthand definition method.
var arr4 = []; Same as ARR2, also an empty array.
Another form of array traversal is the--for in loop statement.
for (Var v1 in array name arr1) { //Here is the loop body, which is a traversal loop specifically for the array arr1, where the value of V1 is the subscript value representing each item of the array. //v1 is just a "temporary variable" that represents each subscript, which in turn changes from 0 to the maximum subscript of the array. }
Property:
Arr.length: Indicates the length of the array object
Method:
Arr.concat (Other array): joins two arrays to become a new "longer" array.
Vars1 = V1.concat (v2); At this point S1 is such an array: [2, 5, 1, 5, 5, 1, 6, 8];
Arr.join ("string"): All items in the array are "strung together" into "long" strings with the specified characters.
var s2 = v1.join ("//"); Result S2 As string "2//5//1//5"
Arr.pop (); Removes the last item of the array (delete) and returns the item data, that is, the array is missing one item
var s3 = V1.pop (); The result v1 only this: [2,5,1]; The value of S3 is 5.
Arr.push (new data item D1); Adds a new data D1 to the last position of the array, that is, the array has one more item.
var S4 = V1.push (55); V1 at this point: [2,5,1, +], the value of S4 is the length of the new array, that is, 4
Arr.shift (); "Remove" the first item of the array (delete) and return the item data, that is, the array is missing one item
var S5 = V1.shift (); The result v1 only this: [5, 1,55]; The value of S5 is 2.
Arr.unshift (new data item D1); Adds a new data D1 to the first position of the array, that is, the array has one more item.
var V6 = V1.unshift (66); V1 at this time: [5, 1, S6], the value of the new array is the length, that is, 4
Property
Length
Method
Concat ()
var arr = Arr1.concat (ARR2); ARR1 = [ARR2] = [4,5,6] At this time arr is [1,2,3,4,5,6]
Join ()
Concatenate the array with the specified characters into a string arr.join (' | ');
Pop ()
Remove the last item of the divisor Arr.pop ();
Push ()
Add a new cell Arr.push (' abc ') at the end of the array;
Shift ()
Move the first item of an array and return as a result Arr.shift ()
Unshift ()
Add new data to the front of the array, Arr.unshift (' ad ');