1. length attribute, which varies with the number of arrays. You can also manually set the syntax expression: numVar = arrayObj. the length2.concat () method returns a new array consisting of two or more arrays.
1. The length attribute, which varies with the number of arrays. You can also set it manually.
Syntax expression: numVar = arrayObj. length
2. The concat () method returns a new array consisting of two or more arrays.
Syntax expression: arr1.concat (arr2), indicating connecting arr2 to the end of arr1
3. push () adds the new element to an array and returns the new Length Value of the array.
Syntax expression: arrayObj. push ([item1 [item2 [... [itemN]) can be multiple arrays
4. pop () removes the last element from the array and returns the element.
Syntax expression: arr. pop ()
5. shift () removes the first element from the array and returns the element.
Syntax expression: arr. shift ()
6. unshift () inserts the specified element into the starting position of the array and returns the array.
Syntax expression: arr. unshift ("element 1", "element 2 ")
7. Convert the array elements into strings toString () and join ()
Syntax expression: arr. toString () arr. join ("separator ")
8. reverse () returns an Array object whose element order is reversed.
Syntax expression: arr. reverse ()
Example:
Script var arr = new Array ("abc", 123); var arr1 = new Array ("php"); document. write (arr. length +"
"); // 2document. write (arr. concat (arr1) +"
"); // Abc, 123, phpdocument. write (arr. push (" php ") +"
"); // 3document. write (arr. pop () +"
"); // Php click document. write (arr. shift () +"
"); // Running result: abc now the arr array has only 123 elements left with document. write (arr. unshift (" book ") +"
"); // Result 2 returns the array document. write (arr +"
"); // Book, 123document. write (arr. toString () +"
"); // Book, 123document. write (arr. join ("-") +"
"); // Book-123document.write (arr. reverse () +"
"); // 123, book script