SOURCE

var arr=new Array("ni","shi","zhu","ma","?");
document.write(arr[2]+"</br>");

arr[2]="bushi";

document.write(arr[2]+"</br>");

arr[5]="!";

document.write(arr+"</br>");

arr[8]="555";

document.write(arr+"</br>");

arr.slice(0,2);

document.write("获取数组的长度"+arr.length+"</br>");

document.write("获取数组的某一段"+arr.slice(0,2)+"</br>");

document.write("往数组头添加元素"+arr.unshift("wo")+"</br>");

document.write(arr+"</br>");

document.write("往数组尾添加元素"+arr.push("wo")+"</br>");

document.write(arr+"</br>");

document.write("数组头删除"+arr.shift()+"</br>");

document.write(arr+"</br>");


document.write("数组尾删除"+arr.pop()+"</br>");

document.write(arr+"</br>");

arr.sort();

document.write("排序"+arr+"</br>");

var numArr=[3,6,9,1,4,11];

function compare(a,b){
    if(a>b){
        return 1;
    }
    if(a==b){
        return 0;
    }
    if(a<b){
        return -1;
    }
}

numArr.sort(compare);

document.write(numArr+"</br>");

function downcompare(a,b){
    if(a>b){
        return -1;
    }
    if(a==b){
        return 0;
    }
    if(a<b){
        return 1;
    }
}

numArr.sort(downcompare);

document.write(numArr+"</br>");

document.write(numArr.reverse()+"</br>");

document.write(numArr+"</br>");

document.write(numArr.join(":")+"</br>");

function ArrZh(str){
    var str1 = str.split("").join("><");
    var arr = str1.split("");
    arr.unshift("<");
    arr.push(">");
    var result = arr.join("");
    return result;
}

document.write(ArrZh("十大大苏打")+"</br>");























console 命令行工具 X clear

                    
>
console