数组值循环后拿不到
//创建数组
var arr = ['*','##',"***","&&","****","##*"];
arr[7] = "**";
//数组长度
var l = arr.length;
//删除数组中非*的项
for(var i = 0;i < l; i++){
var val = arr[i];
if(val != undefined) {
var newarr = val.split('');
var newl = newarr.length;
for(var j = 0; j < newl; j++){
if(newarr[j] != '*'){
arr.splice(i, 1);
break;
}
}
}
}
通过循环后拿不到arr[2]="***"和arr[4]="****",不知道什么原因?循环外面是可以拿到的。求高人指点?