好,可惜 splice 方法 要求版本 5.5

解决方案 »

  1.   

    修改成适合版本3<script>
    function Array.prototype.removeItem(index){
    return this.slice(0,index).concat(this.slice(index+1));
    }
    function Array.prototype.removeLeft(count){
    return this.slice(count);
    }
    function Array.prototype.removeRight(count){
    return this.slice(0,-count);}var a=[0,1,2,3,4,5];
    a=a.removeLeft(2)
    a=a.removeRight(1)
    a=a.removeItem(1)
    alert(a)
    </script>
      

  2.   

    倒,,上面有个地方帖错了。。帖了两次的indexOf , 应该是这个:
    function Array.prototype.left(length)
    {
    return this.slice(0,length);
    }
    function Array.prototype.mid(start,length)
    {
    return this.slice(start,start+length);
    }
    function Array.prototype.right(length)
    {
    if(length>=this.length)return this.concat();
    return this.slice(this.length-length,this.length);
    }