// Array division in javascript var colors = ["red", "green", "blue"]; // alert (colors. toString (); alert (colors. join ("|"); // The returned result is red | green | bluevar colors = ["red", "green", "blue", null]; alert (colors. join ("| ")); // red | green | blue | // note that when the value in the array is null or undefined, the returned result is expressed as an empty string ----------------------------------------- // Delete the array and add var colors = ["red ", "green", "blue"]; // alert (colors. toString (); colors. push ("white", "test"); // The returned result is the array length alert (colors. join ("|"); // The result is red | green | blue | white | test // Add the element var colors = ["red ", "green", "blue", "test"]; var item = colors. unshift ("first"); // Add an element alert (colors. join ("|"); // return the final array // Delete the element var colors = ["red", "green", "blue", "test"]; var item = colors. pop (); // return the delete option result testalert (colors. join ("|"); // returns the final array result red | green | blue // deletes the starting element var colors = ["red", "green ", "blue", "test"]; var item = colors. shift (); // Delete the first alert (colors. join ("|"); // return the final array ----------------------------------------------- // array sequence example // Reverse Order var colors = ["red", "green", "blue ", "test"]; colors. reverse (); alert (colors); // The result is: test, blue, green, red // array sorting var values = [, 7]; values. sort (compare); alert (values); // document. writeln (values);} function compare (value1, value2) {if (value1 <value2) {return 1;} else if (value1> value2) {return-1 ;} else return 0;} --------------------------------------------------- // Add the array concat () method var colors = ["color", "red"] to the array; var colors2 = colors. concat (["ccc", "bbbb"], '20140901', ['vvccxx', ['oolll', 'lll']); alert (colors2 ); // The returned result is: color, red, ccc, bbbb, 3333, vvccxx, oolll, lll // slice () copying the elements in the array does not destroy the previous element var colors = ["color", "red", 'eee', '000000']; var colors2 = colors. slice (1); // copy alert (colors2) from 1; // The result is: red, eeee, 221111var colors = ["color", "red ", 'eeeee', '000000']; var colors2 = colors. slice (3rd); // copy from 1 to locations and end alert (colors2); // The result is red, eeee --------------------------------------------------------------------- // Delete the element var a = [1, 2, 3, 5, 8] in the array; var r =. splice (); // Delete the first two alert (a); // The result is, 8var a = [, 8]; var r =. splice (100,200, 2nd); // delete an item starting from 100 and insert 200 1,100,200 alert (a); // The result is, 8