【 tulaoshi.com - Web开发 】
script type="text/javascript"
Array.prototype.insert = function(vVal,nIdx) {
var arrTemp = this;
if(nIdxarrTemp.length) nIdx=arrTemp.length;
if(nIdx-arrTemp.length) nIdx=0;
if(nIdx0) nIdx = arrTemp.length + nIdx;
for(var ii=arrTemp.length; iinIdx; 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