splice删除数组一段连续的元素,返回被删除的元素数组,slice获取数组中的部分元素
var arr:Array = ["a","b","c","d","e","f","g"];
arr.splice(删除点的索引,要删除的个数,新元素1,新元素2);
arr.splice(2,3,"o","p","q");//从索引为2开始,删除3个元素,并插入3个新元素"o","p","q"
arr.splice(-2,3,"o","p","q");//从倒数为2的索引开始,删除3个元素,并插入3个新元素"o","p","q"
arr.splice(2,3);//cuplayer.com提示:单纯的删除从索引2开始的3个元素(不插入)
arr.splice(2);//cuplayer.com提示:单纯的删除从索引2开始的所有元素(不插入)
arr.splice(2,0,"x","y","z");//在索引2的后面插入3个新元素(不删除)
slice
获取数组中的部分元素
var arr:Array = ["a","b","c","d","e","f","g"];
var newArr:Array = arr.slice();//极酷播放器提示浅复制数组
var newArr:Array = arr.slice(2);
var newArr:Array = arr.slice(-2);
var newArr:Array = arr.slice(2,5);