var arr1=[1,2,3,4,5,6];
document.write(arr1.length+"<br/>")
document.write(arr1.slice(2,5)+"<br/>");
arr1.unshift(10)
document.write(arr1+"<br/>");
arr1.push(0);
document.write(arr1+"<br/>");
arr1.shift();
document.write(arr1+"<br/>");
arr1.pop();
document.write(arr1+"<br/>");
document.write(arr1.sort()+"<br/>");
var nunArr=[6,8,3,2,4];
function upcompare(a,b){
if(a>b){
return 1;
}
if(a==b){
return 0;
}
if(a<b){
return -1;
}
}
nunArr.sort(upcompare);
document.write("升序排序:"+nunArr+"<br/>")
function downcompare(a,b){
if(a>b){
return -1;
}
if(a==b){
return 0;
}
if(a<b){
return 1;
}
}
nunArr.sort(downcompare);
document.write("降序排序:"+nunArr+"<br/>")
var arr2=["one","two","three"];
document.write("反转数组:"+arr2.reverse()+"<br/>");
document.write("默认join数组:"+arr2.join("-")+"<br/>");
var str="绿叶学习网";
var str1=str.split("").join("><");
document.write(str1+"<br/>");
var str2=str1.split("");
document.write(str2+"<br/>");
str2.unshift("<")
document.write(str2+"<br/>");
str2.push(">");
document.write(str2+"<br/>");
document.write(str2.join("")+"<br/>");
console