function writeDocument(variable) {
document.write(variable + "<br/>");
}
//数组
var arr = ["HTML","CSS","JavaScript","jQuery","Vue.js"];
writeDocument(arr[2]);
writeDocument(arr);
arr[4]="React.js";
writeDocument(arr);
arr[5]="Vue.js";
writeDocument(arr);
arr[8]="Angular.js";
writeDocument(arr);
//获取数组长度
var arr=["小羊真可爱","yangyangyang","zhangzhangzhang"];
writeDocument(arr);
writeDocument(arr.length);
writeDocument(arr.slice(0,3));
writeDocument(arr.push(1,2,3));
writeDocument(arr.unshift("啦啦啦"));
writeDocument(arr.shift(1));
writeDocument(arr.pop(2));
writeDocument("升降序排序......***...........");
//定义一个升序函数
function up(a, b)
{
return a - b;
}
//定义一个降序函数
function down(a, b)
{
return b - a;
}
//定义数组
var arr = [3, 9, 1, 12, 50, 21];
arr.sort(up);
document.write("升序:" + arr.join("、") + "<br/>");
arr.sort(down);
document.write("降序:" + arr.join("、")+ "<br/>");
var str1 = "绿叶学习网";
var str2 = str1.split("").join("><");
var arr = str2.split("");
arr.unshift("<");
arr.push(">");
var result = arr.join("");
document.write(result);
console