SOURCE

function writeDocument(variable) {
    document.write(variable + "<br/>");
} 

writeDocument("数组创建----------------------------------");
var arr=["HTML","CSS","JavaScript","jQuery","Vue.js" ];
writeDocument(arr);

writeDocument("数组下标题----------------------------------");
writeDocument(arr[2]);

writeDocument("数组赋值----------------------------------");
arr[4]="React.js";
writeDocument(arr);

arr[5]="Vau.js";
writeDocument(arr);

arr[8]="Angular.js";
writeDocument(arr);


writeDocument("获取数组的长度----------------------------------");
writeDocument("数组的长度是:"+arr.length);

writeDocument("获取数组1-2号元素----------------------------------");
writeDocument("数组1-2号元素"+arr.slice(1,3));
 
writeDocument("在数组头添加元素----------------------------------");
writeDocument("在数组头添加元素"+arr.unshift("python","java"));
writeDocument(arr);

writeDocument("在数组尾添加元素----------------------------------");
writeDocument("在数组尾添加元素"+arr.push("C++"));
writeDocument(arr); 

writeDocument("删除数组第一个元素----------------------------------");
writeDocument("删除元素:"+arr.shift());
writeDocument(arr);

writeDocument("删除数组的最后一个元素------------------------------");
writeDocument("删除元素:"+arr.pop());
writeDocument(arr);
 

writeDocument("对字符串数组按升序排序------------------------------");
writeDocument(arr.sort());

var numArr=[3,4,11,12,9,10];
function upCompare(left,right){
    if(left-right>0){
        return 1;
    }
    if(left-right==0){
        return 0;
    }
    if(left-right<0){
        return -1;
    }
}
    function downCompare(left,right){
    if(left-right>0){
        return -1;
    }
    if(left-right==0){
        return 0;
    }
    if(left-right<0){
        return 1;
    }
}
writeDocument("打印排序前的数组数组"+numArr);
writeDocument("打印升序排序数字数组"+numArr.sort(upCompare));
writeDocument("打印降序排序数字数组"+numArr.sort(downCompare));


writeDocument("反转数组------------------------------");
writeDocument(numArr.reverse());
writeDocument(numArr.join(";"));
writeDocument(numArr.join("<"));


writeDocument("给字符添加尖括号-------------------------");
function addAngleBracket(strValue){
   var strArr=strValue.split("");
   var strValue2=strArr.join("><");
   strArr=strValue2.split("");
   strArr.unshift("<");
   strArr.push(">");
    return strArr.join("");
}
var strValue="绿叶学习网";
writeDocument(strValue);
writeDocument(addAngleBracket(strValue)); 
console 命令行工具 X clear

                    
>
console