unshift(1);//头部添加添加元素
shift(1);//shift(1)头部删除元素
var b= a.indexOf("e");//返回这个字(e)第一个的下标
var b= a.lastIndexOf("e");//返回这个字(e)最后一个的下标
var a=["a","b","c","d","e"];
var b= a.push("22","333")
alert(a);//结果"a","b","c","d","e","22","333"
alert(b);//结果是7
var b= a.push("22","333");在尾部添加
var c= a.pop(1);在尾部删除
var a=["a","b","c","d","e","f","g"];
var b= a.slice(2,4);//提取数组中指定的连续子集,前包括,后不包括。输出c,d
//alert(a);
alert(b);
splice(开始删除(替换、增加)位置的下标,删除元素的长度,要选择插入或替换的内容):
1. 删除操作:删除数组的任意位置元素
2. 插入操作:在数组的任意位置插入元素
3. 替换操作: 在数组的替换任意元素
var a=["a","b","c","d","e","f","g"];
var b= a.splice(3,4);//从下标3开始,删除4个数字
alert(a);
alert(b);
var a = ["我", "爱", "中", "国"];
var b = a.splice(3, 0,"华人民共和");//从下标3开始,删除0个数字,插入"华人民共和"数字
alert(a);
alert(b);