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);
writeDocument("数组的长度为"+arr.length);
writeDocument("数组1-2号元素是"+arr.slice(1,3));
writeDocument(arr.unshift("aeb","Technology"));
writeDocument(arr);
writeDocument(arr.push("Bootstrop","Sass"));
writeDocument(arr);
writeDocument("删除元素"+arr.shift());
writeDocument(arr);
writeDocument("删除元素"+arr.pop());
writeDocument(arr);
writeDocument(arr.sort());
var numArr=[3,6,9,1,4,13];
writeDocument("排序前"+numArr);
function upcompare(a,b){
if(a>b){
return 1;
}
if(a==b){
return 0;
}
if(a<b){
return -1;
}
}
numArr.sort(upcompare);
writeDocument("升序排序后"+numArr);
function downcompare(a,b){
if(a>b){
return -1;
}
if(a==b){
return 0;
}
if(a<b){
return 1;
}
}
numArr.sort(downcompare);
writeDocument("降序排序后"+numArr);
writeDocument("反转数组"+numArr.reverse());
writeDocument("默认join数组"+numArr.join("-"));
writeDocument(""+numArr.join("><"));
function add(strValue){
var strArr=strValue.split("");
console.log(strArr);
var str=strArr.join("><");
console.log(str);
strArr=str.split("");
console.log(strArr);
strArr.unshift("<");
strArr.push(">");
console.log(strArr);
return strArr.join("");
}
writeDocument(add("绿叶学习网"));
console