(1) Join function: Converts and joins all elements in an array to a string. Cases:
[JavaScript]View Plaincopyprint?
- function Joindemo ()
- {
- var a, b;
- A = NewArray (0,1,2,3,4);
- b =a.join ("-"); //Delimiter
- return (b); //Return to b== "0-1-2-3-4"
- }
(2) Length function: Returns the lengths of the array. Cases:
[JavaScript]View Plaincopyprint?
- function Lengthdemo ()
- {
- var a, l;
- A = NewArray (0,1,2,3,4);
- L = a.length;
- return (L); //l==5
- }
(3) Reverse function: Reverses the order of the array elements. Cases:
[JavaScript]View Plaincopyprint?
- function Reversedemo ()
- {
- var a, l;
- A = new Array (0,1,2,3,4);
- L = A.reverse ();
- return (L);
- }
(4) sort Function: Reorder the elements of the array. Cases:
[JavaScript]View Plaincopyprint?
- function Sortdemo ()
- {
- var a, l;
- A = NewArray ("X","y","D", "Z","V","M","R");
- L = A.sort ();
- return (L);
- }
(5) toString Function: Converts an array into a string, concatenated by commas.
(6) valueOf function: The same as the ToString function.
(7) concat function: Connect the other array to the end of the current array.
(8) shift Function: Deletes the first element in the array and returns the value of the deleted element.
(9) pop function: Deletes the last element.
(10) Push function: Adds one or more elements to the tail end and returns the length of the array after the addition.
(11) unshift function: Add one or more elements to the first end
(12) Slice (start,end) function: intercepts a segment element of an array, starting at the end of the array if start is a negative number
Array functions of JavaScript