push(),pop(),shift(),unshift(),splice(),join(),concat(),sort(),split(),parseInt()
// 数组----------------------------------------------------------------------------------------
var arr=[1,2,3];
var arr=new Array(1,2,3); //数组定义
arr.push(4); //尾部压入4
alert(arr);
arr=[1,2,3];
arr.unshift(4); //头部压入4
arr=[1,2,3];
arr.pop(); //弹出最后一个
arr.shift(); //弹出第一个
alert(arr);
arr=[1,2,3,4,5,6,7,8];
arr.splice(2,3); //中间删除,结果:1,2,6,7,8
arr=[1,2,3,4,5,6,7,8];
arr.splice(5,0,‘a‘,‘b‘,‘c‘); //中间插入,结果:1,2,3,4,5,a,b,c,7,8
arr=[1,2,3,4,5,6,7,8];
arr.splice(1,2,‘a‘,‘b‘); //替换,结果:1,a,b,4,5,6,7,8
arr=[1,2,3,4];
arr.length=10;
alert(arr[6]); //结果:undefined
arr=[1,2,3,4];
arr.join(‘:‘); //结果:1:2:3:4
//字符排序
vvar arr=[‘float‘, ‘zindex‘, ‘xy‘, ‘absolute‘, ‘blue‘, ‘leo‘];
arr.sort(); //结果:[‘absolute‘,‘blue‘,‘float‘,‘leo‘,‘xy‘,‘zindex‘]
//数字排序
var arr=[96, 8, 12, 72, 33, 118];
arr.sort(function(num1,num2){return num1-num2;}); //结果:8,12,33,72,96,118
//数组遍历
var obj={a: 5, b: 3, c: 98};
var attr=‘‘;
for(attr in obj){alert(attr+‘=‘+obj[attr]);} //结果依次弹出:a=5,b=3,c=98
// 字符串--------------------------------------------------------------------------------------
var arr1=[1,2,3];
var arr2=[6,7,8];
arr1.concat(arr2); //数组连接,结果:1,2,3,6,7,8
var arr1="sdsafkasd";
var arr2="55131535";
arr1.concat(arr2); //字符串连接,结果:sdsafkasd55131535
var str=‘12-4-5-8‘;
var arr=str.split(‘-‘); //字符串分割成数组,结果:[12,4,5,8]
var str=‘12‘;
parseInt(str)+1; //字符串转换为数字,结果:13,否则121