<script type="text/javascript">
Array.prototype.insert = function(vVal,nIdx) {
var arrTemp = this;
if(nIdx>arrTemp.length) nIdx=arrTemp.length;
if(nIdx<-arrTemp.length) nIdx=0;
if(nIdx<0) nIdx = arrTemp.length + nIdx;
for(var ii=arrTemp.length; ii>nIdx; ii--) {
arrTemp[ii]= arrTemp[ii-1];
}
arrTemp[nIdx]=vVal;
return arrTemp;
}
var arr=["w","w","w","i","e","c","n","n","e","t"];
alert(arr.join(""));
arr.insert(".",3);
alert(arr.join(""));
arr.insert(".",-3);
alert(arr.join(""));
</script>
您可能感兴趣的文章: