1、js数组置顶元素置顶
myAppList:即要操作的数组
index:要置顶的元素序号
function upIndex(myAppList,index) {// 置顶
if (index == 0) {
return;
}
swapItems(myAppList, index, 0);
}
index2:要替换至第几位
var swapItems = function(arr, index1, index2) {
arr.unshift(arr[index1]);
arr.splice(index1+1,1);
return arr;
}