SOURCE

 var arr = ["HTML", "CSS", "JavaScript"];  //数组赋值
        arr[2] = "jQuery";
        document.write(arr[2]);
        var arr = ["HTML", "CSS", "JavaScript"];
        arr[3] = "jQuery";
        document.write(arr);
 document.write("..................................................<br/>")

 document.write("1.获取数组的长度............................"+"<br/>")
var arr1 = [];  //获取数组长度
        var arr2 = [1, 2, 3, 4, 5, 6];
        //输出数组长度
        document.write(arr1.length + "<br/>");
        document.write(arr2.length+ "<br/>");
       document.write("2.获取数组1-2号元素............................"+"<br/>")
        document.write(arr[1] +"<br/>");
        document.write(arr[2] +"<br/>");
    
       document.write("3.往数组头添加元素............................"+"<br/>")
        var fyk = ["JavaScript", "jQuery"]; // 往数组头添加元素
        fyk.unshift("HTML", "CSS");
        document.write(fyk+"<br/>");
         
       document.write("4.往数组尾添加元素............................"+"<br/>")
        var fyk = ["HTML", "CSS","JavaScript", "jQuery"]; // 往数组尾添加元素
        fyk.push("jQuery");
        document.write(fyk+"<br/>");

       document.write(" 5.删除数组中第一个元素............................"+"<br/>")
        var fyk = ["HTML", "CSS","JavaScript", "jQuery"]; // 删除数组中第一个元素
        fyk.shift("HTML");
        document.write(fyk+"<br/>");

       document.write(" 6.删除数组中最后一个元素............................"+"<br/>")
        var fyk = ["HTML", "CSS","JavaScript", "jQuery"]; // 删除数组中最后一个元素
        fyk.pop("jQuery");
        document.write(fyk+"<br/>");

        document.write("7..对字符串数字进行升序排列......................."+"<br/>")
        document.write(fyk.sort()+"<br/>");  //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;
            }
        }
        document.write("打印排序前的数字数组:"+numArr+"<br/>");
        document.write("打印升序排列后的数字数组:"+numArr.sort(upCompare)+"<br/>");
        document.write("打印降序排列后的数字数组:"+numArr.sort(downCompare)+"<br/>");


 document.write("给字符添加尖括号--------------"+"<br/>");
function addAngleBracket(strValue){
    var strArr=strValue.split("");
    console.log(strArr);
    var strTempValue=strArr.join("><");
    console.log(strTempValue);
    strArr=strTempValue.split("");
    strArr.unshift("<");
    console.log(strArr);
    strArr.push(">");
    console.log(strArr);
    return strArr.join("");
}
var strValue = "绿叶学习网";
document.write(strValue+"<br/>");
document.write(addAngleBracket(strValue));


console 命令行工具 X clear

                    
>
console