调用方式方法,
<script> function delArray(StrArr,Str,zt){ var index=0 for(var i=0;i<StrArr.length;i++){ if(StrArr[i]===Str){ index = i; break; }; }; if (zt=="l"){ StrArr.splice(0,index) ; }else if (zt=="r"){ StrArr.splice(index+1,StrArr.length); }else{ StrArr.splice(0,index); StrArr.splice(1,StrArr.length); } return StrArr; }; var arr2 =["111","222","333","444","555","666","777","888"]; arr2=delArray(arr2,"555",""); console.log(arr2); </script>
吉公网安备 22020202000301号