push方法
var arr=["a","b","c","d"];
arr.push("d","e");
console.log(arr);
print: ["a", "b", "c", "d", "d", "e"]
pop方法
var arr=["a","b","c","d"];
var last =arr.pop();
console.log(last);
print: d
console.log(arr);
print: ["a", "b", "c"]
unshift方法
var arr=["a","b","c","d"];
arr.unshift("1","2",3,4);
console.log(arr);
print:["1", "2", 3, 4, "a", "b", "c", "d"]
shift方法
var arr=["a","b","c","d"];
var first=arr.shift();
console.log(first);
print: a
console.log(arr);
print: ["b", "c", "d"]
concat方法
var arr1=["a","b","c","d"];
var arr2=["我","是","数","组"];
arr = arr1.concat(arr2,["东","南","西","北"],"end");
console.log(arr1);
print:["a", "b", "c", "d"]
console.log(arr2);
print:["我", "是", "数", "组"]
console.log(arr);
print: ["a", "b", "c", "d", "我", "是", "数", "组", "东", "南", "西", "北", "end"]
slice方法
var arr=["a","b","c","d","e","f","g","h"];
0:"a"
1:"b"
2:"c"
3:"d"
4:"e"
5:"f"
6:"g"
7:"h"
length:8
arr2=arr.slice(1,4);
console.log(arr2);
print: ["b", "c", "d"]
arr3=arr.slice(4);
console.log(arr3);
print: ["e", "f", "g", "h"]
arr4=arr.slice(-4,-2);
console.log(arr4);
print: ["e", "f"]
arr5=arr.slice(-4);
console.log(arr5);
print: ["e", "f", "g", "h"]
arr6=arr.slice(-1,-4);
console.log(arr6);
print:[]
arr7=arr.slice(3,3);
console.log(arr7);
print: []
arr8=arr.slice(3,1);
console.log(arr8);
print: []
splice方法
var arr=["A","B","C,","D","E","F","G"];
arr.splice(3,2,"X","Y","我","是","数","组");
console.log(arr);
print: ["A", "B", "C,", "X", "Y", "我", "是", "数", "组", "F", "G"]
var arr=["A","B","C,","D","E","F","G"];
arr.splice(2,4,"一");
console.log(arr);
print: ["A", "B", "一", "G"]
var arr=["A","B","C,","D","E","F","G"];
arr.splice(2,4);
console.log(arr);
print: ["A", "B", "G"]
var arr=["A","B","C,","D","E","F","G"];
arr.splice(4,2);
console.log(arr);
print: ["A", "B", "C,", "D", "G"]
var arr=["A","B","C,","D","E","F","G"];
arr.splice(4);
console.log(arr);
print: ["A", "B", "C,", "D"]
var arr=["A","B","C,","D","E","F","G"];
arr.splice(4,0,"我","是","数","组");
console.log(arr);
print: ["A", "B", "C,", "D", "我", "是", "数", "组", "E", "F", "G"]
reverse方法
var arr=[1 ,"A","我","C,","二","E","F","G"];
arr.reverse();
console.log(arr);
print: ["G", "F", "E", "二", "C,", "我", "A", 1]
sort方法
var arr =["33",1,"27",12,53,10,0,"4","a","c","A","B","C","b"];
arr.sort();
console.log(arr);
print: [0, 1, 10, 12, "27", "33", "4", 53, "A", "B", "C", "a", "b", "c"]
join方法
var arr=[1,2,3];
var str=arr.join("");
console.log(str);
print: 123
console.log(typeof str);
print: string