//Array division var colors = ["red","green","blue"];//alert(colors.toString());alert(colors.join("|")); //Return result is red|green|bluevar colors = ["red","green","blue",null];alert(colors.join("|"));//red|green|blue|//Note that when there is a value in the array that is null or undefined, the result returned is represented by an empty string ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ["red","green","blue"];//alert(colors.toString());colors.push("white","test");//The result is the length of the array alert(colors.join("|"));//The result is red|green|blue|white|test//Add element var colors = ["red","green","blue","test"];var item = colors.unshift("first");//Add an element alert(colors.join("|"));//Return the last array//Delete the element var colors = ["red","green","blue","test"];var item = colors.unshift("first");//Add an element alert(colors.join("|"));//Return the last array//Delete the element var colors = ["red","green","blue","test"];var item = colors.unshift("first");//Add a element alert(colors.join("|"));//Return the last array//Delete the element var colors = ["red","green","blue","test"];var item = colors.unshift("first");//Add a element alert(colors.join("|"));//Return the last array//Delete the element var colors = ["red","green","blue","test"];var item = colors.unshift("first");//Add a element alert(colors.join("|"));//Return the last array//Delete the element var colors = ["red","green","blue","test"];var item = colors.unshift("first");//Add a element alert(colors.join("|"));//Return the item = colors.pop();//Return the deleted option result testalert(colors.join("|"));//Return the last array result red|green|blue//Delete the beginning element var colors = ["red","green","blue","test"];var item = colors.shift();//Delete the first option of the array alert(colors.join("|"));//Return the last array -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ["red","green","blue","test"];colors.reverse();alert(colors);//The result is: test,blue,green,red//Array sort var values = [0,1,5,10,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 ;} -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- colors.slice(1);//Copy alert(colors2);//The result is: red,eeee,221111var colors = ["color","red",'eeee','221111'];var colors2 = colors.slice(1,3);//Copy from 1 to the third position end alert(colors2);//The result is red,eeee------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ [1,2,3,5,8];var r = a.splice(1,1,100,200); //Delete the item from the second number and insert 100 200alert(a); //The result is 1,100,200,3,5,8